Exemplo n.º 1
0
    private void Rotate()
    {
        Vector3 direction = new Vector3(
            inputScript.GetAxis("PlayerStrafe"),
            0f,
            inputScript.GetAxis("PlayerForward")
            );

        if (direction == Vector3.zero)
        {
            return;
        }

        Quaternion cameraRotationFlat = camera.transform.rotation.Flatten();

        Quaternion rotation = Quaternion.LookRotation(cameraRotationFlat * direction);

        rotation = Quaternion.Slerp(rigidbody.rotation, rotation, Time.fixedDeltaTime * rotationSmoothing);
        rigidbody.MoveRotation(rotation);
    }
Exemplo n.º 2
0
    private void TakeInput()
    {
        rotationInput = new Vector3(inputScript.GetAxis("ShipPitch") * pitchMultiplier, inputScript.GetAxis("ShipYaw") * yawMultiplier, inputScript.GetAxis("ShipRoll") * rollMultiplier);
        takeOff       = inputScript.GetButton("ShipTakeOff");
        landShip      = inputScript.GetButton("ShipLand");
        exitShip      = inputScript.GetButton("ShipExit");

        if (spaceship.ShipState == SpaceShipState.FLYING)
        {
            if (inputScript.GetButton("ShipThrottleUp"))
            {
                throttle += 0.7f * Time.deltaTime;
            }

            if (inputScript.GetButton("ShipThrottleDown"))
            {
                throttle -= 0.7f * Time.deltaTime;
            }

            throttle = Mathf.Clamp01(throttle);
        }
    }