Ejemplo n.º 1
0
        protected override void BindInput(InputComponent playerInputComponent)
        {
            base.BindInput(playerInputComponent);

            // Bind the jump action to Character.Jump(), which already has the appropriate delegate signature.
            playerInputComponent.BindAction(InputAction.Jump, InputEventType.Pressed, Jump);
            playerInputComponent.BindAction(InputAction.Jump, InputEventType.Released, StopJumping);

            playerInputComponent.BindAxis(InputAxis.MoveForward, MoveForward);
            playerInputComponent.BindAxis(InputAxis.MoveRight, MoveRight);

            // We have 2 versions of the rotation bindings to handle different kinds of devices differently
            // "turn" handles devices that provide an absolute delta, such as a mouse.
            // "turnrate" is for devices that we choose to treat as a rate of change, such as an analog joystick
            playerInputComponent.BindAxis(InputAxis.Turn, AddControllerYawInput);
            playerInputComponent.BindAxis(InputAxis.TurnRate, (float axisValue) => AddControllerYawInput(axisValue * BaseTurnRate * World.GetWorldDeltaSeconds()));
            playerInputComponent.BindAxis(InputAxis.LookUp, AddControllerPitchInput);
            playerInputComponent.BindAxis(InputAxis.LookUpRate, (float axisValue) => AddControllerPitchInput(axisValue * BaseLookUpRate * World.GetWorldDeltaSeconds()));

            // handle touch devices
            playerInputComponent.BindTouch(InputEventType.Pressed, (fingerIndex, location) => Jump());
            playerInputComponent.BindTouch(InputEventType.Released, (fingerIndex, location) => StopJumping());

            // VR headset functionality
            playerInputComponent.BindAction(InputAction.ResetVR, InputEventType.Pressed, OnResetVR);
        }