예제 #1
0
    private void UpdateAngles()
    {
        Vector2 rightStick = controlManager.GetAxisRight();

        Vector2 mouseChange = controlManager.GetMouseMovement();

        angleX = angleX + mouseChange.y + (rightStick.y * StickTurnSensitivity);

        if (angleX > 180)
        {
            angleX = angleX - 360;
        }
        else
        {
            if (angleX < -180)
            {
                angleX = angleX + 360;
            }
        }

        if (angleX < -90 || angleX > 90)
        {
            //upside down
            upsideDown      = true;
            Physics.gravity = new Vector3(0, 9.8f, 0);

            angleY = angleY - mouseChange.x - (rightStick.x * StickTurnSensitivity);
        }
        else
        {
            //right side up
            upsideDown      = false;
            Physics.gravity = new Vector3(0, -9.8f, 0);


            angleY = angleY + mouseChange.x + (rightStick.x * StickTurnSensitivity);
        }
    }