ExampleSpin.cs 828 B

1234567891011121314151617181920212223242526272829
  1. using UnityEngine;
  2. namespace Chronos.Example
  3. {
  4. // A basic example for Chronos with deltaTime movement.
  5. // In this case, rotate the game object in a framerate independant
  6. // manner that takes into consideration all the time scales.
  7. public class ExampleSpin : ExampleBaseBehaviour
  8. {
  9. // The speed at which to rotate
  10. public float speed = 20;
  11. private void Update()
  12. {
  13. // Notice time.deltaTime (GetComponent<Timeline>().deltaTime)
  14. // instead of Time.deltaTime! Lowercase t is important here.
  15. // Remember "time" is defined in ExampleBaseBehaviour.
  16. if (time.timeScale > 0)
  17. {
  18. transform.Rotate(time.deltaTime * Vector3.one * speed);
  19. }
  20. // We don't need to take care of negative time scales,
  21. // as the transform recorder will kick in for us because
  22. // we enabled Timeline.rewindable.
  23. }
  24. }
  25. }