summaryrefslogtreecommitdiff
path: root/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Vector3/Normalize.cs
blob: 64c583b7ef563e96093aecd0ad1829086609880b (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
using UnityEngine;

namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityVector3
{
    [TaskCategory("Basic/Vector3")]
    [TaskDescription("Normalize the Vector3.")]
    public class Normalize : Action
    {
        [Tooltip("The Vector3 to normalize")]
        public SharedVector3 vector3Variable;
        [Tooltip("The normalized resut")]
        [RequiredField]
        public SharedVector3 storeResult;

        public override TaskStatus OnUpdate()
        {
            storeResult.Value = Vector3.Normalize(vector3Variable.Value);
            return TaskStatus.Success;
        }

        public override void OnReset()
        {
            vector3Variable = storeResult = Vector3.zero;
        }
    }
}