Where is the best place to add the mapping context?

Hi!

Where do I have to add the mapping context? In the Player Controller? In the player’s character?

Thanks!

Either place is fine, it depends on how you want to control your characters.

We set it up only in the PlayerController, the player controller gets the inputs, then relays them to any controlled characters or vehicles, who all implement a controllable Interface.

So for example, the PlayerController gets “MoveLeft” triggers, then it relays MoveLeft to whatever it is controlling, and anything that implements the controllable interface has MoveLeft functionality.

But setting a different control scheme up in each character type is also a valid way to do it.

1 Like

So, if I set it up only in the Player Controller, code like this:

Should be done in Player Controller, isn’t it?

Thanks!

I’m not sure because I don’t use blueprints. But where to do it shouldn’t be too different .:person_shrugging:

In C++ it is usually in the function PlayerController::SetupInputComponent()

My preference is in the controller along with common UI. You always have a controller, you don’t always have a pawn.

Input events are in the class that uses them.
So IMC in controller, events in character.

Input component checks: Input-Enabled Actor → Controller → Level → Pawn

2 Likes