示例#1
0
    private IEnumerator RotateToTurretDirection()
    {
        Vector3 direction = _turretScript.GetHorizontalDirection();

        while (Quaternion.Angle(_playerTransform.rotation, Quaternion.LookRotation(direction)) > 1f)
        {
            Vector3 newDir = Vector3.RotateTowards(_playerTransform.forward, direction, .05f, 0.0f);

            float angle = Vector3.SignedAngle(_playerTransform.forward, newDir, Vector3.up);
            _physicsController.Aim = new Vector3(Mathf.Rad2Deg * angle / _physicsController.HorizontalRotationSpeed, _physicsController.Aim.y, _physicsController.Aim.z);

            yield return(null);
        }

        _physicsController.Aim = Vector3.zero;
        yield return(new WaitForSeconds(.2f));

        UseTurret();
    }