Exemplo n.º 1
0
        // Do movement
        protected virtual void MovementUpdate()
        {
            // Forward / backward movement
            translationInputs = spaceVehicleEngines.TranslationThrottleValues;
            if (throttleUpInput.Pressed())
            {
                translationInputs.z += throttleSensitivity.z * Time.deltaTime;
            }
            else if (throttleDownInput.Pressed())
            {
                translationInputs.z -= throttleSensitivity.z * Time.deltaTime;
            }

            // Left / right movement
            translationInputs.x = strafeHorizontalInput.FloatValue();

            // Up / down movement
            translationInputs.y = strafeVerticalInput.FloatValue();

            // Boost
            if (boostInput.Down())
            {
                boostInputs = new Vector3(0f, 0f, 1f);
            }
            else if (boostInput.Up())
            {
                boostInputs = Vector3.zero;
            }
        }
        // Set the control values for the vehicle
        void SetControlValues()
        {
            // Values to be passed to the ship
            float pitch = 0;
            float yaw   = 0;
            float roll  = 0;

            Vector3 flattenedForward = new Vector3(engines.transform.forward.x, 0f, engines.transform.forward.z).normalized;

            Maneuvring.TurnToward(engines.transform, engines.transform.position + flattenedForward, new Vector3(0f, 360f, 0f), shipPIDController.steeringPIDController);

            pitch = shipPIDController.steeringPIDController.GetControlValue(PIDController3D.Axis.X);
            roll  = shipPIDController.steeringPIDController.GetControlValue(PIDController3D.Axis.Z);

            yaw = -yawInput.FloatValue();


            // ************************** Throttle ******************************

            Vector3 nextTranslationInputs = engines.TranslationThrottleValues;

            if (throttleUpInput.Pressed())
            {
                nextTranslationInputs.z += throttleSensitivity.z * Time.deltaTime;
            }
            else if (throttleDownInput.Pressed())
            {
                nextTranslationInputs.z -= throttleSensitivity.z * Time.deltaTime;
            }

            // Left / right movement
            nextTranslationInputs.x = strafeHorizontalInput.FloatValue();

            // Up / down movement
            nextTranslationInputs.y = strafeVerticalInput.FloatValue();
            engines.SetTranslationThrottleValues(nextTranslationInputs);


            if (boostInput.Down())
            {
                engines.SetBoostThrottleValues(new Vector3(0f, 0f, 1f));
            }
            else if (boostInput.Up())
            {
                engines.SetBoostThrottleValues(Vector3.zero);
            }

            engines.SetRotationThrottleValues(new Vector3(pitch, yaw, roll));
        }
Exemplo n.º 3
0
        // Update is called once per frame
        protected override void InputUpdate()
        {
            // Moving
            float horizontal = strafeHorizontalAxisInput.FloatValue();
            float vertical   = walkForwardBackwardAxisInput.FloatValue();

            characterController.SetMovementInputs(horizontal, 0, vertical);

            // Jumping
            if (jumpInput.Down())
            {
                characterController.Jump();
            }

#if !MOBILE_INPUT
            characterController.SetRunning(runInput.Pressed());
#endif
        }
Exemplo n.º 4
0
        protected override void InputUpdate()
        {
            if (vehicleCamera != null)
            {
                if (cycleViewForwardInput.Down())
                {
                    vehicleCamera.CycleCameraView(true);
                    if (cameraGimbal != null)
                    {
                        cameraGimbal.ResetGimbal();
                    }
                }
                else if (cycleViewBackwardInput.Down())
                {
                    vehicleCamera.CycleCameraView(false);
                    if (cameraGimbal != null)
                    {
                        cameraGimbal.ResetGimbal();
                    }
                }
            }

            if (vehicleCamera.HasCameraViewTarget && vehicleCamera.SelectedCameraViewTarget.CameraView == VehicleCameraView.Interior)
            {
                if (cameraGimbal != null)
                {
                    if (enableLookAroundInput.Pressed())
                    {
                        // Look around
                        cameraGimbal.Rotate(new Vector2(cameraGimbalRotationSpeed * horizontalRotationAxisInput.FloatValue(),
                                                        cameraGimbalRotationSpeed * -verticalRotationAxisInput.FloatValue()));
                    }

                    if (enableLookAroundInput.Up())
                    {
                        cameraGimbal.ResetGimbal();
                    }
                }
            }
        }
Exemplo n.º 5
0
        protected override void InputUpdate()
        {
            // Cycle camera view
            if (cameraEntity != null)
            {
                if (cycleViewForwardInput.Down())
                {
                    cameraEntity.CycleCameraView(true);
                }
                else if (cycleViewBackwardInput.Down())
                {
                    cameraEntity.CycleCameraView(false);
                }
            }

            // Select camera view
            for (int i = 0; i < cameraViewInputs.Count; ++i)
            {
                if (cameraViewInputs[i].input.Down())
                {
                    cameraEntity.SetView(cameraViewInputs[i].view);
                }
            }

            // Free look mode
            if (cameraGimbalController != null)
            {
                if (freeLookModeInput.Pressed())
                {
                    cameraGimbalController.Rotate(lookHorizontalInput.FloatValue() * freeLookSpeed,
                                                  -lookVerticalInput.FloatValue() * freeLookSpeed);
                }
                else if (freeLookModeInput.Up())
                {
                    cameraGimbalController.ResetGimbal(true);
                }
            }
        }