Enhanced Input | Combo System | Input Buffer | Unreal Engine Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hello everyone today I'll show you how to use the new enhanced input Action System in Unreal Engine 5. it allows it to easily copy and transfer your input actions into mappings from Project to project it also have some functionalities built in that previously you needed to code yourself in Blueprint or C plus plus now you have them ready just to use by picking up a drop down I'll show you how to make a combo action system with this new triggers functions let's start first by loading the enhanced input plugin so choose the edit menu and then plugins start typing enhanced and make sure that this enhanced input plugin is loaded click the checkbox it will ask you to restart the engine and after you have the plugin loaded and you restarted the engine go into your project settings then go into the input section scroll down and make sure that you have default player input class set as enhanced player input and default input component class set as enhanced input component these are the new types used with the enhanced player input system and here all these old mappings that are set up for the basic input system you don't really need they're actually deprecated you should be using the new system and it's really a better system anyway so I'll delete all those just to make sure that we don't have anything that we'll just get in our way later delete everything make sure you have no mappings here and we'll create everything into the new inputs system go ahead and close the project settings window and we'll start with creating the actions to create the actions just create for yourself a folder called input and then one folder inside call actions we'll create our our actions here and it will be very easy to copy into other projects that you want to use the same input system right click here choose input and then click on the input action let's start with the move action we'll call it input action move this will be controlled by our W ASD keys or the left thumbstick power controller or the arrow keys anything you want then I'll continue with another action it will be done walk action we'll control that with the mouse or the right thumbstick just to look around our character both of these input actions should have a type of access to the when you open an input action it has a value type selection box it has a value type drop down where you'll see all the pre-made types digital which will be only on or off axis 1D will go from -1 to 1. axis 2D will go from -1 to 1 but it will have two values for the two axis and 3D will have of course three for movement we want this axis to the type because we will move forward and back in the one axis and left and right for the other axis and also for our look input action we want it to be Vector 2D as well because we will look up and down and left and right let's save everything and let's see how to set up the case that will control the movement and attach them to our character blueprint let's go into the input folder right click and then in the input section choose input mapping context let's call it import mapping context in-game for example this will be the context when we're controlling our character you can create more contexts and I'll show you later how this can be useful and how to change between them but for now let's start with just one in this context you create your mapping similar to the old mapping system that was done in the input section in the project settings here you have the action mappings and axis mappings and in your input Action System you create the same mappings for the keys that were done in the old system as well so in the mapping section click on the plus sign and choose the move input action we'll create the mappings for the movement of our character by clicking here on this keyboard you can then click the key that you want to map so I'll press the W key now and you can see that immediately it's automatically selected here I'll add another mapping it will be the S key another one with the a and the last one with d these are the four keys for our movement input and what you will need to set up here is the modifiers that will control how this value is mapped to your character when you press any of these Keys into this action by default every value is mapped on the first axis and the value range is from 0 to 1 and if you want to change that you need to use the modifiers section here let me explain what we will do here if this is our character and we want to move in the four directions we have two axes one for the up and back and one for the left and right and if we pick our zero point to be here where they meet and this is the x-axis and this is the y-axis our forward movement should be on the y-axis from 0 to 1. our backwards movement will be on the y-axis from 0 to -1 our right moment will be our x-axis from 0 to 1. and left movement will be our x-axis from 0 to -1 is what we'll set up now into our mappings so for the Y Movement we don't want to use the first axis which will be the X1 we want to use the y-axis and this is done by the modifier so click on the add element here into the modifiers tab and you want to choose the Swizzle input axis values this will move the input from the x axis to the y-axis let's suppose this W key will control now the y-axis movement from 0 to 1 then for the S key we want the same Swizzle input axis value because we'll control the y-axis movement but we want also to change the values from 0 to -1 so we want additional modifier click on the add element again and then choose the negate modifier so our W key will control the y-axis values from 0 to 1 and the S key the y-axis value from 0 to -1 with this negative modifier we are ready with the w and S the D key which will be moved right will control the x axis value from 0 to 1 we don't want any modifiers for this and the a key we just want to negate the value in order to have the values from 0 to -1 so add a modifier negate and this will change our values for a k from 0 to -1 this should be everything that we need in order to control our our character movement with our four keys let's save this and let's go into our character blueprint to show you how to use this action mappings to control your character I have deleted everything related to the input mappings that is coming with the default blueprint so I can redo it now and show you how it's done so starting with the begin play event go into your character's event graph find the begin play event or if you don't have it just right click and type begin and find this begin play event so on the begin play event you want to get your character controllers so right click and start typing get controller and choose this get Control Function you need to cast that controller to the one that is used by your character blueprint so in this case is cast to player controller this should be the controller that you're using with your character blueprint in the case of the third person character demo scene that is provided with the unreal it called player controller so that's why we are casting to this controller next drag off this as player controller pin here and type get enhanced input vocal player subsystem choose this and now check if this is valid and if this walkout player subsystem is valid let's create a branch by holding b key and pressing left Mouse click here connect it here this will be the condition so if our local pair subsystem is valid now we want to add our mapping context that we created with the w and ASD keys inside so drag off our enhanced input local player subsystem and start typing add context and this add mapping context function should appear connect it to the true statement of our Branch here and inside here into the mapping context drop down you should select the input mapping context that we created earlier so input mapping context in-game and this will make sure that our mapping context is used when we begin play with our third person character so let's compile and save here and let me show you how our values will be controlled by the wasd keys by creating a temporary event when we press any of the keys so all the keys are set up in our mapping context to control the input action move event if I choose this event here and on triggered State I'll print a string and into our string I'll connect this action value here and now let's compile and Save and when I press play you can see the top left part of the screen when I hold the W key I have values 0 for x and one for y because we Swizzle our input for the W key from the x-axis to the y-axis if I release the W key and now hold the S key I have a 0 for x and -1 for y because of the Swizzle and the negate modifiers for the Decay I have one for x and 0 for y because we don't have any additional modifiers and for the a key I have -1 for x and 0 for egreg because of the negate modifier okay let's exit from the game and go back to our character blueprint instead of printing our values let's actually use them to control our movement let's go down here into the movement input right click start typing input action underscore then move this hour move action and we want our triggered States tool this is what is executed every frame for the axis values connect to the add movement input for our character let's split this pin we'll use the x value for going left and right and our y value for going forward and backward and our modifiers will control the the range from -1 to 1 for the both axis this will be our x-axis and forward backwards will be our y-axis let's compile and Save and by the way these are the default movement functions for the third person character you can create any additional features for your characters but this is just the basic movement forward and back and left and right let's now test this let's hit play and now I can move forward and back with the w and the S keys and left and right with the A and D keys let's exit the game it's really easy to set up the input actions with the new system and now that we have a mapping context and actions created here as a separate objects into our content folder we can easily copy them into another project and set up the controls there it's much better than the previous system where everything was set up in the project settings window and you could not copy it easily to any other project [Music] let's continue with the setup for the look action let's go back to our blueprint first actually we need to setup here the mappings into our mapping context let's add another mapping and this will be for our location and here what we'll need to choose is our Mouse x y axis this will control our look action values let's do the same as we did with the other action just right click type input action then look connect our triggered action here let's split this pin and use our x value for the left and right and our y value for the up and down compile and Save and now if I hit play on the game I can easily look around my character now now let's make one additional action which will be our jump so right click input create an input action call it input action jump and this time the value type will stay as a digital Boolean so it will be on or off it will not have an axis value of 0 to 1 it will be just true or false let's save this let's open the input mapping context that we created earlier create another mapping this time it will be for the jump click on the keyboard click on the space bar and this will map your jump to the space bar let's save this go into our character blueprint and let's connect our jump input action when we have the triggered state it will start the jump and when we release the key so on the completed event we'll stop jumping let's compile and Save let's hit the play button while I'm holding the spaced bar the character is continuously jumping if I release the space bar it immediately stops jumping and I will now show you how to do combo moves instead of just the simple Action commands let's go back into the mapping context and for the jump let's add a trigger and the trigger type will be combo when you choose the combo trigger type it automatically removes the mapping here for the key that you have selected and create a new mapping here inside with an array for the combo actions here you need to put all the actions that you want to be triggered in the order that you want them to be triggered if we want to execute our jump action we'll need to execute all the actions set up here into the combo actions into the order that we have specified here and into the time frame that we have chosen for each action and only then our jump action will be executed let's create a couple additional actions so we can control this jump movement let's delete this for now so we can save the mapping context without the setup for the jump and now into our actions folder I'll create a new folder and call this the combo actions and this combo actions will contain all the actions that we want to use to control our combo mappings I'll create one action for each Direction with the wasd case and one additional action which will trigger our combo if we have pressed the the right directions in the right order let's create four input actions for the four directions the first one will be input action up and they will all be the type of digital Boolean so it's the default type we don't need to open and change anything just create four actions and one additional action I call it in protection combo let's save everything go into the mapping context and now let's create a mapping for for our input action jump let's select the trigger as a combo and inside the combo actions let's add three actions just as an example let's say we want to have press up then up again and then the combo action and for each of them we want to have 0.5 seconds so half a second for each of these keys and we'll need to create the mappings for this up and combo actions let's click again on the add mapping let's choose the up it will be our W key add another mapping folder combo and this will be our space key now instead of having mapped the jump action to the space key as before we have it map to execute only if we press twice the up action which is our W key and then the combo action which is our space bar let's save this close this window and if I play the game if I press the space bar nothing happens but if I press Twice The W and then the space bar I'm now executing the the jump command you can create any Comics you like this way let's hit escape and create some additional combo just to show you how it's done with multiple combos I'll need to add here all the mappings for the different directions actions down will be s left will be a and right will be D I can use all these directions and the combo key which is the space bar currently to trigger different actions for the combos let's create into combo actions into our actions folder additional action let's call it for example punch and let's make a new mapping here for the punch action let's add a trigger type type combo and inside here for combo actions let's add again three elements let the punch be for example up then down and then the com key which is our space bar let's save this going back into our character blueprint and let's make some code for our input action punch let's add a print string and on trigger let's write to our screen punch let's compile and Save and if I hit play and now when I press from back up down and then space in the top left corner that I'm executing the punch action it is writing this punch command to our screen you can set up any additional commands in the same way and also if you want to change the order of the commands that are executed here you can drag the inputs up and down so now I need to start by pressing down then up and then com key maybe I would like to add another element between the down and up and it will be left so now I will need to press down left and up to execute my punch command let's hit play let's hit down left up then space and [Music] in the top left the punch command is executed another important thing from for the enhanced input system is that you can have multiple input mapping contexts and you can change between them in your blueprint let's create another input mapping context let's call it input mapping context special let's go inside and create mapping for our jump action and the mapping will be the space bar now let's go into our in-game mapping and remove our jump mapping now we don't have the ability to jump into our in-game mapping system we need to have the other mapping context active in order to jump and you can control that in your blueprint you can add the context in the beginning like you did for the in-game mapping I can just copy this connect it to our enhanced inputs player subsystem and choose for the mapping context the special context that way I'll have both of my input mapping context active in the beginning let's hit play and if I press the space bar I'm activating the the jump action because I have my special input context active from the beginning but the other way you can do that is you can for example just add it after you execute the punch command instead of printing the punch string I'll add a mapping context and it will be our special context and we need to add it to the local subsystem now when you begin the game you have only the mapping context called in-game and it doesn't have any mapping for the jump action you will not be able to execute the jump when you start the game when you execute the punch input action only after that when you add this mapping context you'll be able to execute the jump action let's compile and save and test that if I hit the space bar now I cannot jump I can move but I cannot jump because I have my movement mappings into the in-game subsystem but the special one contains the the jump mapping now let's execute the punch command by hitting back left up and then space and now I should have added the other subsystem and you can see I'm immediately able to use the space bar for jumping now in that way you can add and remove mapping contexts based on your actions for example in a fighting game you can add a mapping context when you're in the air to execute special abilities while in the air if you're making for example a skating game when you have jumped in the air you are able to execute your tricks but while you're riding on the ground you cannot do any tricks because you need to jump first in order to flip your board or you can have different tricks when you're on the ground with the same combo action Keys set up to a different context that's why we're on ground and different context while in the air and you start to see that the new enhanced input mapping system is very flexible and allows you to do a lot of things with very little quotes set up in the blueprint everything is handled by this subsystem for the combo actions that we created anything you can imagine it's very easily done with that new system it has other different triggers I'll not show all of them but most of them have very good explanations in the tooltip so you can see what they do for example you can use the hold trigger instead of the combo one and if I set it up for the T key I'll execute the jump action when holding the T key for one second let's save and close and when I plan play my game I have only the in-game input mapping context so I cannot jump with the space bar but if I hold the t key for one second I'm executing the jump command so I press D and after one second my jump action is active let's hold t for one second and release it [Music] this uh triggers and modifiers types of settings into the new system are great for a variety of different actions that you want to set up and by adding and removing context based on your actions you can have different systems play at different times in your game depending on your actions and it's very versatile system it's easily copied into other projects so I highly encourage you to start using this new enhanced input Action System to control your characters that's everything that I wanted to show for today if you have any questions please write in the comments and for any additional ideas for tutorials again write in the comments please like this video And subscribe it will help a lot to continue doing these tutorials and I'll see you in the next one [Music] thank you
Info
Channel: DK 3D
Views: 1,935
Rating: undefined out of 5
Keywords:
Id: LEOWK0pn9h8
Channel Id: undefined
Length: 34min 26sec (2066 seconds)
Published: Sat Feb 04 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.