This can be used with a Pawn or Character derived player character, since it´s necessary to have a player controller to set the player input local subsystem to use a IMC (Input mapping context). There are 3 basic steps (1- create a input action prefixed with IA_; 2- create a input mapping context that will use the previously created IA, prefixed with IMC_; and last but not least, 3- in script, C++ or blueprint, set the IMC to be used in the player controller).
1- Create a Input Action. E.g., IA_FireLaser
While in the content browser open the context menu and in the Input section choose to create a Input Action
This IA is used as a boolean value (ON or OFF) to indicate if should fire weapon if user is pressing a mouse button or keyboard key.
2- Create a Input Mapping Acton. E.g., IMC_Player
This IMC binds left mouse button and Z key to this fire event.
3- In script (C++ or blueprint) on begin play event:
3.1- get controller
3.2- cast to player controller
3.3- get enhanced input local player subsystem
3.4- add mapping context (this example is using IMC_PlayerBot in the Add Mapping Context node MappingContext field)
And finally,
4- in script (C++ or blueprint) create a binding
4.1- open context menu (clicking or pressing tab)
4.2- type the name of the input action associated with the imc previously set for this player
4.3- link “Triggered” with a function that fire the gun/spawns the laser
Keep learning, Unreal is very broad, and there is so much to learn 👍👍👍🆒🆒🆒
Top comments (0)