arthurdiniz0_outer-math/OuterMath Unity Project/Assets/PlayMaker/Actions/Vector3/Vector3Normalize.cs
// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved.
// BUG FIX: http://hutonggames.com/playmakerforum/index.php?topic=476.0;topicseen

namespace HutongGames.PlayMaker.Actions
{
	[ActionCategory(ActionCategory.Vector3)]
    [Tooltip("Normalizes a Vector3 Variable. A normalized vector has a length of 1.")]
    public class Vector3Normalize : FsmStateAction
	{
		[RequiredField]
		[UIHint(UIHint.Variable)]
        [Tooltip("The Vector3 Variable to normalize.")]
        public FsmVector3 vector3Variable;

        [Tooltip("Repeat every frame.")]
        public bool everyFrame;

		public override void Reset()
		{
			vector3Variable = null;
			everyFrame = false;
		}

		public override void OnEnter()
		{
			vector3Variable.Value = vector3Variable.Value.normalized;
			
			if (!everyFrame)
			{
				Finish();
			}		
		}

		public override void OnUpdate()
		{
			vector3Variable.Value = vector3Variable.Value.normalized;
		}
	}
}

