SlothController.RotateSloth C# (CSharp) 메소드

RotateSloth() 개인적인 메소드

Rotate the transform based on given rotation, time and curve
private RotateSloth ( Vector3 rotation, float animTime, AnimationCurve animCurve ) : IEnumerator
rotation Vector3 Rotation to do in degrees
animTime float Time of the animation
animCurve UnityEngine.AnimationCurve Curve at which to execute rotation
리턴 IEnumerator
    IEnumerator RotateSloth(Vector3 rotation, float animTime, AnimationCurve animCurve) {
        //_rigidBody.AddTorque(rotation,ForceMode.Impulse);
        float prevI = 0;
        for (float i = 0; i < 1f; i += Time.deltaTime / animTime) {
            float curI = animCurve.Evaluate(i);
            //Get i difference
            float Idiff = curI - prevI;
            //rotate sloth accordingly
            transform.Rotate(Idiff*rotation);
            //Debug.Log("idiff : " + Idiff + "   final rotate : " + Idiff * rotation);
            yield return null;
            prevI = curI;
        }
    }