// (c) Copyright HutongGames, LLC 2010-2012. All rights reserved. using UnityEngine; namespace HutongGames.PlayMaker.Actions { [ActionCategory(ActionCategory.Trigonometry)] [Tooltip("Get the Arc Tangent. You can get the result in degrees, simply check on the RadToDeg conversion")] public class GetAtan : FsmStateAction { [RequiredField] [Tooltip("The value of the tan")] public FsmFloat Value; [RequiredField] [UIHint(UIHint.Variable)] [Tooltip("The resulting angle. Note:If you want degrees, simply check RadToDeg")] public FsmFloat angle; [Tooltip("Check on if you want the angle expressed in degrees.")] public FsmBool RadToDeg; public bool everyFrame; public override void Reset() { Value = null; RadToDeg = true; everyFrame = false; angle = null; } public override void OnEnter() { DoATan(); if (!everyFrame) { Finish(); } } public override void OnUpdate() { DoATan(); } void DoATan() { float _angle = Mathf.Atan(Value.Value); if (RadToDeg.Value) { _angle = _angle*Mathf.Rad2Deg; } angle.Value = _angle; } } }