Angle.cs 878 B

1234567891011121314151617181920212223242526272829
  1. using UnityEngine;
  2. namespace BehaviorDesigner.Runtime.Tasks.Unity.UnityQuaternion
  3. {
  4. [TaskCategory("Unity/Quaternion")]
  5. [TaskDescription("Stores the angle in degrees between two rotations.")]
  6. public class Angle : Action
  7. {
  8. [Tooltip("The first rotation")]
  9. public SharedQuaternion firstRotation;
  10. [Tooltip("The second rotation")]
  11. public SharedQuaternion secondRotation;
  12. [Tooltip("The stored result")]
  13. [RequiredField]
  14. public SharedFloat storeResult;
  15. public override TaskStatus OnUpdate()
  16. {
  17. storeResult.Value = Quaternion.Angle(firstRotation.Value, secondRotation.Value);
  18. return TaskStatus.Success;
  19. }
  20. public override void OnReset()
  21. {
  22. firstRotation = secondRotation = Quaternion.identity;
  23. storeResult = 0;
  24. }
  25. }
  26. }