public static Vector3 Axis(AxisBFT axis) { switch (axis) { case AxisBFT.RIGHT: return(Vector3.right); case AxisBFT.UP: return(Vector3.up); case AxisBFT.FORWARD: return(Vector3.forward); case AxisBFT.LEFT: return(Vector3.left); case AxisBFT.DOWN: return(Vector3.down); case AxisBFT.BACK: return(Vector3.back); default: throw new ArgumentOutOfRangeException("axis", axis, null); } }
public static AxisBFT GetOpposedAxis(AxisBFT axis) { switch (axis) { case AxisBFT.RIGHT: return(AxisBFT.LEFT); case AxisBFT.UP: return(AxisBFT.DOWN); case AxisBFT.FORWARD: return(AxisBFT.BACK); case AxisBFT.LEFT: return(AxisBFT.RIGHT); case AxisBFT.DOWN: return(AxisBFT.UP); case AxisBFT.BACK: return(AxisBFT.FORWARD); default: throw new ArgumentOutOfRangeException("axis", axis, null); } }
public static Vector3 LocalAxis(this UnityEngine.Transform transform, AxisBFT axis) { switch (axis) { case AxisBFT.RIGHT: return(transform.right); case AxisBFT.UP: return(transform.up); case AxisBFT.FORWARD: return(transform.forward); case AxisBFT.LEFT: return(-transform.right); case AxisBFT.DOWN: return(-transform.up); case AxisBFT.BACK: return(-transform.forward); default: return(Vector3.zero); } }
public static Vector3 Axis(AxisBFT axis) { switch (axis) { case AxisBFT.RIGHT: return(Vector3.right); case AxisBFT.UP: return(Vector3.up); case AxisBFT.FORWARD: return(Vector3.forward); case AxisBFT.LEFT: return(-Vector3.right); case AxisBFT.DOWN: return(-Vector3.up); case AxisBFT.BACK: return(-Vector3.forward); default: return(Vector3.zero); } }
public static void AngleEasedSpeedRotate(this UnityEngine.Transform trans, AxisBFT rotationAxis, float finalAngle, float speed, bool localRotation = true, bool localAxis = true) { Vector3 finalEulerAngles = ((localAxis) ? LocalAxis(trans, rotationAxis) : MathExt.Axis(rotationAxis)) * finalAngle; if (localRotation) { trans.localRotation = Quaternion.Euler(Vector3.Lerp(trans.localEulerAngles, finalEulerAngles, speed * UnityEngine.Time.deltaTime)); } else { trans.rotation = Quaternion.Euler(Vector3.Lerp(trans.eulerAngles, finalEulerAngles, speed * UnityEngine.Time.deltaTime)); } }
public static bool IsAxisNegative(AxisBFT axis) { switch (axis) { case AxisBFT.RIGHT: case AxisBFT.UP: case AxisBFT.FORWARD: return(false); case AxisBFT.LEFT: case AxisBFT.DOWN: case AxisBFT.BACK: return(true); default: throw new ArgumentOutOfRangeException("axis", axis, null); } }
public static void AngleDurationRotate(this UnityEngine.Transform trans, Vector3 initialEuler, AxisBFT rotationAxis, float finalAngle, float durationPercent, bool localRotation = true, bool localAxis = true) { Vector3 finalEulerAngles = ((localAxis) ? LocalAxis(trans, rotationAxis) : MathExt.Axis(rotationAxis)) * finalAngle; if (localRotation) { trans.localRotation = Quaternion.Euler(Vector3.Lerp(initialEuler, finalEulerAngles, durationPercent)); } else { trans.rotation = Quaternion.Euler(Vector3.Lerp(initialEuler, finalEulerAngles, durationPercent)); } }