How to assign the same button to two actions with the new input system?

I’m using the new input system, and it was working great, but now I’m having a problem. I have 2 actions with different behaviors, one to jump and climb, both are with the W. But having the same button, the jump button is canceled, and now I can only climb. But I can’t assign the 2 mechanics only to the climb action because this is a 1d axis one and the jump one is just a button. Besides that, it is not the only action that can be with the same button, but different behavior. Is there a way to prevent one of the 2 actions from canceling?

This is what the action maps are for (leftmost pane in the screenshot). Right now you only have “Player”. What you would need is a map “Movement” and another “Climbing” and based on the game situation you switch between those two maps, allowing the same or different keys to be used for same or different actions while climbing.

Alternatively, you can also code this based on context, ie if W (aka “Move Forward”) is pressed the player moves forward (or jumps) unless player is facing or grabbing a ladder at which point player keeps climbing up rather than move forward or jump.

But since you’d have to have a context check anyway it’s easier and safer to just switch action maps, because you can then disable keys you don’t need in that context like left/right movement for instance.

2 Likes

I think it is simpler to use 2 action maps, I ask to know if it can be kept in one because there will be several actions with the same buttons, for example S to crouch and S to go down the stairs, key E to interact and to continue reading dialogues. But I’ll keep the basic ones in the Player map and the not so common ones in another action map. Thank you

In that case you need more action maps. For instance one is “movement” the other might be “jump’n’duck” and also “interact” another “climbing” and so on.

That way you can leave the ones active that you need in the current context while the others are disabled, and at the same time you do not have duplication.