summaryrefslogtreecommitdiff
path: root/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Quaternion/Lerp.cs
blob: faea9019f47130616eb4e96cc12ea0fbcb3b288a (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.UnityQuaternion
{
    [TaskCategory("Basic/Quaternion")]
    [TaskDescription("Lerps between two quaternions.")]
    public class Lerp : Action
    {
        [Tooltip("The from rotation")]
        public SharedQuaternion fromQuaternion;
        [Tooltip("The to rotation")]
        public SharedQuaternion toQuaternion;
        [Tooltip("The amount to lerp")]
        public SharedFloat amount;
        [Tooltip("The stored result")]
        [RequiredField]
        public SharedQuaternion storeResult;

        public override TaskStatus OnUpdate()
        {
            storeResult.Value = Quaternion.Lerp(fromQuaternion.Value, toQuaternion.Value, amount.Value);
            return TaskStatus.Success;
        }

        public override void OnReset()
        {
            fromQuaternion = toQuaternion = storeResult = Quaternion.identity;
            amount = 0;
        }
    }
}