Exemple #1
0
 public static void SetWorldRotation(this Transform trans, float targetAngle, PTAxis axis, float timer)
 {
     trans.StartCoroutineSelf(trans.SetWorldRotationCoroutine(targetAngle, axis, timer));
 }
Exemple #2
0
        public static IEnumerator SetWorldRotationCoroutine(this Transform trans, float targetAngle, PTAxis axis, float timer)
        {
            Vector3 eulerTarget = trans.eulerAngles;

            switch (axis)
            {
            case PTAxis.x:
                eulerTarget = new Vector3(targetAngle, trans.eulerAngles.y, trans.eulerAngles.z);
                break;

            case PTAxis.y:
                eulerTarget = new Vector3(trans.eulerAngles.x, targetAngle, trans.eulerAngles.z);
                break;

            case PTAxis.z:
                eulerTarget = new Vector3(trans.eulerAngles.x, trans.eulerAngles.y, targetAngle);
                break;
            }
            Quaternion rotationTarget = Quaternion.Euler(eulerTarget);

            yield return(trans.SetWorldRotationCoroutine(rotationTarget, timer));
        }