blob: 89f406b956985555ec29163091acfd95a5e7a4cd (
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
|
using UnityEngine;
namespace BehaviorDesigner.Runtime.Tasks.Basic.Math
{
[TaskCategory("Basic/Math")]
[TaskDescription("Clamps the float between two values.")]
public class FloatClamp : Action
{
[Tooltip("The float to clamp")]
public SharedFloat floatVariable;
[Tooltip("The maximum value of the float")]
public SharedFloat minValue;
[Tooltip("The maximum value of the float")]
public SharedFloat maxValue;
public override TaskStatus OnUpdate()
{
floatVariable.Value = Mathf.Clamp(floatVariable.Value, minValue.Value, maxValue.Value);
return TaskStatus.Success;
}
public override void OnReset()
{
floatVariable = minValue = maxValue = 0;
}
}
}
|