blob: c84fd51740a460e0fcd008d2a34f0fcdaab895d9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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;
}
}
}
|