You can not select more than 25 topics 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.

43 lines
1.1KB

  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. namespace coa4u
  5. {
  6. /// <summary>
  7. /// Rotates by the given euler angles.
  8. /// </summary>
  9. class ActionRotateBy : ActionInterval
  10. {
  11. protected Vector3 delta;
  12. public ActionRotateBy(Vector3 targetDelta, float targetDuration)
  13. : base(targetDuration)
  14. {
  15. delta = targetDelta;
  16. }
  17. public ActionRotateBy(float angle, float targetDuration)
  18. : this(new Vector3(0, 0, angle), targetDuration)
  19. {
  20. locks = Axises.rxy;
  21. }
  22. public override ActionInstant Clone()
  23. {
  24. return new ActionRotateBy(delta, duration);
  25. }
  26. public override ActionInstant Reverse()
  27. {
  28. return new ActionRotateBy(delta * -1F, duration);
  29. }
  30. public override void Step(float dt)
  31. {
  32. float d = dt / duration;
  33. Vector3 target = delta * d;
  34. transform.rotation = Quaternion.Euler(transform.rotation.eulerAngles + target);
  35. }
  36. }
  37. }