summaryrefslogtreecommitdiff
path: root/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Vector3/Lerp.cs
blob: 4819bc780945a425275fcd801d6a35a7cf06573a (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.UnityVector3
{
    [TaskCategory("Basic/Vector3")]
    [TaskDescription("Lerp the Vector3 by an amount.")]
    public class Lerp : Action
    {
        [Tooltip("The from value")]
        public SharedVector3 fromVector3;
        [Tooltip("The to value")]
        public SharedVector3 toVector3;
        [Tooltip("The amount to lerp")]
        public SharedFloat lerpAmount;
        [Tooltip("The lerp resut")]
        [RequiredField]
        public SharedVector3 storeResult;

        public override TaskStatus OnUpdate()
        {
            storeResult.Value = Vector3.Lerp(fromVector3.Value, toVector3.Value, lerpAmount.Value);
            return TaskStatus.Success;
        }

        public override void OnReset()
        {
            fromVector3 = toVector3 = storeResult = Vector3.zero;
            lerpAmount = 0;
        }
    }
}