IndieGame/client/Assets/ParadoxNotion/NodeCanvas/Tasks/Actions/Blackboard/EvaluateCurve.cs

29 lines
716 B
C#
Raw Normal View History

2024-10-11 10:12:15 +08:00
using NodeCanvas.Framework;
using ParadoxNotion.Design;
using UnityEngine;
namespace NodeCanvas.Tasks.Actions
{
[Category("✫ Blackboard")]
public class EvaluateCurve : ActionTask
{
[RequiredField]
public BBParameter<AnimationCurve> curve;
public BBParameter<float> from;
public BBParameter<float> to = 1;
public BBParameter<float> time = 1;
[BlackboardOnly]
public BBParameter<float> saveAs;
protected override void OnUpdate() {
saveAs.value = curve.value.Evaluate(Mathf.Lerp(from.value, to.value, elapsedTime / time.value));
if ( elapsedTime > time.value )
EndAction();
}
}
}