Adding Custom Key Rebinds
Last updated
Last updated
New in FPS Engine 1.2
FPS Engine 1.2 introduced Key Rebinding, allowing all provided inputs to be reconfigured in the Main Menu. However, there may be situations where you need to add custom actions and bindings that should also be rebindable.
To start, we need to create the custom action. Open the PlayerActions file located in Cowsins/Inputs.
This window will pop up:
Please note that "All Control Schemes" is selected. Because of that, we will be able to see and edit both inputs for keyboard & mouse and controller.
Click on the "+" Icon to Create a new Action and give it a name.
For each action, you can assign multiple bindings. In this example, we'll add one for the keyboard and one for the controller. First, duplicate the empty binding. Then, modify the path for each binding, making sure to enable either "Keyboard" or "Gamepad" depending on the control scheme for that binding. Save the PlayerActions file and close it.
Navigate to Cowsins/Demo/Main Menu and open the Main Menu scene. Next, locate the Rebind UI Buttons within the scene.
For instance, you can set it to rebind the Keyboard H key from the NewAction action that we just created.
If we change the SelectedBinding to the next index value, we will now be rebinding the Gamepad binding, since it is the next available binding within the action that was created previously.
Just like that, Rebind for a Custom Action is working!
[ IMPORTANT ]
Ensure you gather the input for your custom action through the InputManager, as this implementation won't work otherwise. The InputManager is responsible for handling all the inputs in the game.
You can duplicate any of the Rebind Buttons. Once you select the duplicated button, you'll see it has a component. Here, you can choose the desired action and binding.