Exemplo n.º 1
0
    IEnumerator SwingDoor(Quaternion targetRot, float rotSpeed)
    {
        Quaternion rotPast      = targetRot * Quaternion.Euler(0, rotPastDeg * GF.ClockWise(transform.rotation, targetRot, 1), 0);
        float      timeRotStart = Time.time;

        while (Quaternion.Angle(transform.rotation, rotPast) > Quaternion.Angle(targetRot, rotPast))
        {
            transform.rotation = Quaternion.Slerp(transform.rotation, targetRot, (Time.time - timeRotStart) * rotSpeed);
            yield return(null);
        }
        transform.rotation = targetRot;
    }