Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

37 lines
837B

  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. class ActionRotateBy : ActionInterval
  5. {
  6. protected Vector3 delta;
  7. public ActionRotateBy(Vector3 tgtDelta, float tgtDuration)
  8. : base(tgtDuration)
  9. {
  10. delta = tgtDelta;
  11. }
  12. public ActionRotateBy(float angle, float tgtDuration)
  13. : this(new Vector3(0, 0, angle), tgtDuration)
  14. {
  15. is2d = true;
  16. }
  17. public override Action clone()
  18. {
  19. return new ActionRotateBy(delta, duration);
  20. }
  21. public override Action reverse()
  22. {
  23. return new ActionRotateBy(delta * -1F, duration);
  24. }
  25. public override void stepInterval(float dt)
  26. {
  27. float d = dt / duration;
  28. Vector3 tgt = delta * d;
  29. transform.rotation = Quaternion.Euler(transform.rotation.eulerAngles + tgt);
  30. }
  31. }