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/Vector2/MoveTowards.cs | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Vector2/MoveTowards.cs (limited to 'Client/Assets/Behavior Designer/Runtime/Basic Tasks/Vector2/MoveTowards.cs') diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Vector2/MoveTowards.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Vector2/MoveTowards.cs new file mode 100644 index 00000000..c84fd517 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Vector2/MoveTowards.cs @@ -0,0 +1,31 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityVector2 +{ + [TaskCategory("Basic/Vector2")] + [TaskDescription("Move from the current position to the target position.")] + public class MoveTowards : Action + { + [Tooltip("The current position")] + public SharedVector2 currentPosition; + [Tooltip("The target position")] + public SharedVector2 targetPosition; + [Tooltip("The movement speed")] + public SharedFloat speed; + [Tooltip("The move resut")] + [RequiredField] + public SharedVector2 storeResult; + + public override TaskStatus OnUpdate() + { + storeResult.Value = Vector2.MoveTowards(currentPosition.Value, targetPosition.Value, speed.Value * Time.deltaTime); + return TaskStatus.Success; + } + + public override void OnReset() + { + currentPosition = targetPosition = storeResult = Vector2.zero; + speed = 0; + } + } +} \ No newline at end of file -- cgit v1.1-26-g67d0