選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
このリポジトリはアーカイブされています。 ファイルの閲覧とクローンは可能ですが、プッシュや、課題・プルリクエストのオープンはできません。

44 行
1.0KB

  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. namespace coa4u
  5. {
  6. class ActionMoveTo : ActionInterval
  7. {
  8. protected Vector3 value;
  9. protected Vector3 path;
  10. public ActionMoveTo(Vector3 tgtValue, float tgtDuration)
  11. : base(tgtDuration)
  12. {
  13. value = tgtValue;
  14. }
  15. public ActionMoveTo(Vector2 tgtValue, float tgtDuration)
  16. : this((Vector3)tgtValue, tgtDuration)
  17. {
  18. is2d = true;
  19. }
  20. public override ActionInstant clone()
  21. {
  22. return new ActionMoveBy(value, duration);
  23. }
  24. public override void start()
  25. {
  26. base.start();
  27. if (is2d)
  28. value.z = transform.position.z;
  29. path = value - transform.position;
  30. }
  31. public override void stepInterval(float dt)
  32. {
  33. float d = dt / duration;
  34. Vector3 tgt = path * d;
  35. transform.Translate(tgt, Space.World);
  36. }
  37. }
  38. }