25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

44 lines
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. }