Dont know how it works. Watched too many tutorials already.
Please give me better links to better tuts.
No mat aspland or other generic youtubers please. Ive been through them and am left knowing even less.
Dont know how it works. Watched too many tutorials already.
Please give me better links to better tuts.
No mat aspland or other generic youtubers please. Ive been through them and am left knowing even less.
This is for unreal engine 5.1, UE4 has an extra step of going into the project settings and turning the enhanced input system on.
Step 1 - Create a new blank project, scalable quality, with starter content if you want to do step 10. After the level opens, go to file, new level, basic. This is optional, but there is no need for a landscape or high quality here.
Step 2 - Right click content browser, select blueprint class, select pawn. This is going to be the pawn that owns the player controller that has the mapping context assigned to it.
Step 3 - Right click the content browser, select blueprint class, select gamemode base. Open the gamemode bp and under the default pawn class, assign the pawn blueprint you just created. In world settings, set the game mode override to the gamemode blueprint you just created. Drag a player start into the level.
Step 4 - Make an input action. Right click the content browser and select input, then input action. The only thing you need to do with this file is change the âValue Typeâ to a float value if you are using this key for something like an analogue stick, or change it to a 2d vector if you want to use this input action for the mouse XY. By default it is a boolean value, which is good for single key presses.
Step 5 - Make an Input mapping context. Right click content browser and select input, then input mapping context.
Step 6 (picture below)- Open the INPUT MAPPING CONTEXT and hit the + next to mapping. Expand it if it does not auto expand. In the first field, assign the INPUT ACTION you just created. In the second field, assign the key you wish to use to trigger it. If you want to use this input as the mouse XY values, select the drop down menu, expand the mouse section, and select mouse XY 2d-axis. Completely ignore the triggers and modifiers section for now.
Step 7 (picture below) - Assign the INPUT MAPPING CONTEXT to the player controller you want to use it. How this is done depends on what you plan on doing with the mapping context. In this example the input mapping context is going to contain all of the inputs related to the players pawn, like moving or punching someone in the ear, so I am going to initialize the input mapping context when the pawn is created. Open the pawn blueprint you created and right click the event graph. Select get player controller, drag from that and get enhanced input local player subsystem, drag from that and then select add mapping context, select the mapping context you created from the nodes dropdown menu. Plug the add mapping context into begin play, so that it is loaded when the pawn is loaded.
Step 8. Right click in the pawns event graph, type the name of the INPUT ACTION you made, and select it as an event.
Step 9. Make 3 print string nodes. Plug one into started that outputs âstartedâ, do the same for triggered, do the same for completed. Check results, if everything is working good move on to step 10.
Step 10. Make a game. I would suggest adding a static mesh, spring arm, and camera to your pawn, and trying to figure out how to move it and the camera around with your new inputs. GL.
Triggered - This fires every frame while âtriggeredâ. If no new trigger is added, the default trigger is âdownâ. It will fire any time the keys value is not at its default. For single key presses this means âtriggeredâ will fire every frame the key is held down. The mouseXY axis will fire every frame that mouse movement is detected. If you add a hold trigger, and set the hold time to 5 seconds, trigger will not fire until the key has been held down for 5 seconds, and then it will fire every frame until the key is released, or just once if âone shotâ is enabled. Iâd recommend getting a solid understanding of the enhanced input system before learning the various triggering methods.
Started - This will fire once when key is pressed no matter what. Even if you set the input value to trigger after the key is held for 5 seconds, this will still fire once when the held timer first starts. For the Mouse XY, this will fire once when the mouse starts to move and wonât fire again until a frame passes where mouse movement isnât detected.
Ongoing - This will fire each frame that the key is pressed, but not yet triggered. If I have an action that triggers after the key is held for 5 seconds, ongoing will fire every frame during that 0 - 5 second period, and then stop when the action triggers or button is released. If the trigger is default type(down) I donât think this does anything.
Cancelled - This will fire once if the condition for triggering was started but not completed. If I have an action that triggers after the key is held for 5 seconds and I hold the key for 3 seconds and release it before it reaches 5 seconds, cancelled will fire one time. If the trigger is default type(down) I donât think this does anything.
Completed - Will fire one time if the action is completed. The default trigger will cause this to fire whenever the key is pressed down and released. If I have an action that triggers after the key is held for 5 seconds, this will fire one time after it is held for 5 seconds if the trigger is âone shotâ. If the trigger is not one shot completed will fire when you release the key. For the mouseXY axis, this will fire whenever the mouse stops moving.
Some things to note;
Pay close attention to the words fired and triggered. Fired means the code executed, triggered means the conditions were met and the trigger fired. Hopefully I didnât mix them up anywhere.
Adding a new trigger completely changes when each output from the enhanced action node fires, except for started. I donât think the behavior of started ever changes no matter which trigger you use.
You can set triggers and modifiers up in the mapping context or the input action, but it will only be necessary to put them in the input actions file in very specific circumstances. I recommend keeping all triggers and modifiers in the input mapping context so they are better organized, and only put them in the input actions file when needed.
The actuation value is the value that key needs to exceed in order for the input to fire at all. If it is a boolean input value, and you set the actuation value to 1.1, it can never fire because a booleans value is only 1. If you were using an analogue stick and you only wanted the event to trigger if the stick was pushed more than halfway, you would set the actuation value to .5.
The input actions can be fired from any event graph if it has input enabled for the player controller that was assigned the context. Pawns and character blueprints have this enabled by default, actor blueprints do not. To use inputs from inside an actor blueprint, right click in its graph, âget player controllerâ, drag off that to an âenable inputâ node and plug the player controller into it, leaving the target field empty.
You can also put input actions directly into the player controller blueprint, but you first have to make a new player controller blueprint because you canât modify the default one(I am not 100% sure on this). An example of how this can be used - The game starts and the main menu loads, the player controller activates and inside of it are basic controls to navigate the menu and they are saved in a context mapping. When the level starts and the pawn is loaded, the context mapping for the player controller is shut off and the context mapping for the player pawn is initialized.
Try not to get frustrated with it, didnât seem to help me. Itâs great once you learn it.
Step 6
Step 7,8,9
Is there a way to set a trigger to check if a key is NOT pressed?
I have a chord trigger to allow the input action to fire when W, A, or D is also pressed, but I do not know how to set it so it will not fire, or will cease firing, if S is pressedâŚ
Iâve tried adding âSâ and settings the modifier to negate but that does nothing.
Thanks Bro it works now!
hi i am new to unreal and my question might be a bit dumb so i apologize in advance. Is it possible to add the mapping context to a custom player controller blueprint performing step 7,8 and 9 in the player controller blueprint rather than in the character blueprint?
I know Unreal wants us to do it that way cos there in one of the starter projects âStack O Botâ it is briefly mentioned in the BP_bot character blueprint
Yes, one of the best things about this new system is that, being able to add or remove inputs from anywhere without having any reference to the player or the controller, even in the widget!
Very helpful, thank you!
thanks !!!
This topic has been moved from Tutorial & Course Discussion to Programming & Scripting.
When posting, please review the categories to ensure your topic is posted in the most relevant space. If you would prefer a different category, feel free to @ me and Iâll be happy to move the thread once again.
Thanks and happy developing!