Files
beyond/Assets/ThirdParty/PlayMaker/Actions/Vector2/Vector2Normalize.cs
2024-11-20 15:21:28 +01:00

40 lines
785 B
C#

// (c) Copyright HutongGames, LLC 2010-2016. All rights reserved.
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Vector2)]
[Tooltip("Normalizes a Vector2 Variable.")]
public class Vector2Normalize : FsmStateAction
{
[RequiredField]
[UIHint(UIHint.Variable)]
[Tooltip("The vector to normalize")]
public FsmVector2 vector2Variable;
[Tooltip("Repeat every frame")]
public bool everyFrame;
public override void Reset()
{
vector2Variable = null;
everyFrame = false;
}
public override void OnEnter()
{
vector2Variable.Value = vector2Variable.Value.normalized;
if (!everyFrame)
{
Finish();
}
}
public override void OnUpdate()
{
vector2Variable.Value = vector2Variable.Value.normalized;
}
}
}