summaryrefslogtreecommitdiff
path: root/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Math/FloatAbs.cs
blob: 16c2e345b18186bb0c187307fb79285944caf047 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
using UnityEngine;

namespace BehaviorDesigner.Runtime.Tasks.Basic.Math
{
    [TaskCategory("Basic/Math")]
    [TaskDescription("Stores the absolute value of the float.")]
    public class FloatAbs : Action
    {
        [Tooltip("The float to return the absolute value of")]
        public SharedFloat floatVariable;

        public override TaskStatus OnUpdate()
        {
            floatVariable.Value = Mathf.Abs(floatVariable.Value);
            return TaskStatus.Success;
        }

        public override void OnReset()
        {
            floatVariable = 0;
        }
    }
}