From 97da432c35b8c7aaf9dd2c39e2aa4b1f55f36065 Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 27 Jan 2021 16:15:06 +0800 Subject: +behaviour designer --- .../Runtime/Basic Tasks/Vector3/RotateTowards.cs | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Vector3/RotateTowards.cs (limited to 'Client/Assets/Behavior Designer/Runtime/Basic Tasks/Vector3/RotateTowards.cs') diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Vector3/RotateTowards.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Vector3/RotateTowards.cs new file mode 100644 index 00000000..e012d875 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Vector3/RotateTowards.cs @@ -0,0 +1,33 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityVector3 +{ + [TaskCategory("Basic/Vector3")] + [TaskDescription("Rotate the current rotation to the target rotation.")] + public class RotateTowards : Action + { + [Tooltip("The current rotation in euler angles")] + public SharedVector3 currentRotation; + [Tooltip("The target rotation in euler angles")] + public SharedVector3 targetRotation; + [Tooltip("The maximum delta of the degrees")] + public SharedFloat maxDegreesDelta; + [Tooltip("The maximum delta of the magnitude")] + public SharedFloat maxMagnitudeDelta; + [Tooltip("The rotation resut")] + [RequiredField] + public SharedVector3 storeResult; + + public override TaskStatus OnUpdate() + { + storeResult.Value = Vector3.RotateTowards(currentRotation.Value, targetRotation.Value, maxDegreesDelta.Value * Mathf.Deg2Rad * Time.deltaTime, maxMagnitudeDelta.Value); + return TaskStatus.Success; + } + + public override void OnReset() + { + currentRotation = targetRotation = storeResult = Vector3.zero; + maxDegreesDelta = maxMagnitudeDelta = 0; + } + } +} \ No newline at end of file -- cgit v1.1-26-g67d0