if I wanted to display “Press [space] to open door”, where [space] is the name of the mapped key, is this possible with the new input system? So depending on what the user has this bound to, it could say “Press E to open door” or “Press X button to open door”?
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/manual/ActionBindings.html
inputAction.bindings[X].overridePath
inputAction
is your inputAction, X
is the index of the binding.
See also Input Bindings | Input System | 1.0.2, Actions | Input System | 1.0.2
I hope I was not too concise.
Thank you so much, I’ll try that!
Is it possible to find a binding index by the active inputcontrol scheme?
Say I have inputAction.bindings[0].name
for a gamepad, and inputAction.bindings[1].name
for keyboard, how would I return the correct binding without hardcoding the x
index?
For anyone stumbling upon this the answer is here:
Link to doc
In short, action.GetBindingDisplayString();
6 Likes
A little late but for anyone who stumbles upon this I found a solution.
PlayerInput playerInput;
private void Start()
{
playerInput = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerInput>(); //Just my code to get the player input action map.
Debug.Log(playerInput.currentActionMap.FindAction("Jump").GetBindingDisplayString(0)); // Replace the "Jump with the name of the action you have in your action map and the GetBindingDisplayString(0) the 0 is the order in the array of keybinds set to the action, so 0 will be the first one"
}
2 Likes