Example #1
0
    IEnumerator CameraRotating(float time, GameObject target)
    {
        if (m_Gyro != null)
        {
            m_Gyro.ActiveGyroscope(false);
        }

        float _endTime = time, _nowTime = 0f;

        Quaternion targetRotation
            = Quaternion.LookRotation(target.transform.position - m_MainCamera.transform.position);

        while (_nowTime < _endTime)
        {
            targetRotation
                = Quaternion.LookRotation(target.transform.position - m_MainCamera.transform.position);

            m_MainCamera.transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, (Time.fixedDeltaTime + _nowTime / _endTime) * m_RotateSpeed);
            _nowTime += Time.fixedDeltaTime;
            yield return(new WaitForFixedUpdate());
        }

        if (m_Gyro != null)
        {
            m_Gyro.ActiveGyroscope(true);
        }

        yield return(null);
    }