Creating Character Movement With The New Enhanced Axis Mappings In Unreal Engine 5 (Tutorial)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys and welcome back to another unrelation 5 tutorial so in today's video we're going to be going over is creating character movement for your player with the new input action mapping system in Unreal Engine 5.1 and Beyond so again as you know the input system has changed and I have done a basic video on that as well but today I'm going to be carrying the axis mappings as well as the input mappings so we can actually create our character movement so if we hit play what we can see is we're just going to have a very basic character in which we can move the camera around we can move forwards backwards left right and even jump as well so all of our basic character movement including camera we're going to be creating and setting up today so this is only going over and creating today so without further Ado let's delete this code and I'll show you how I've done it so as you can see I'm just in a completely blank project so I have nothing else in here other than the start content now see you don't have to do that if you don't want to but I'm just doing that to show you that I'm not doing anything else I'm creating the character from scratch so the first thing I'm going to do is we want to actually start creating our inputs so we can actually then control the player later on so to do that we're going to hit control space and I'm going to create a new folder called character or characters in here I'm going to create another folder called inputs and then in here what I'm going to do is right click go to input and create an input action I'm going to name this I a for input action and I'm going to do moving first so let's just name this move we don't need to move forward and we don't need to move left right like we did in the old version we can do it in just one now so we're gonna have move and we're going to open it up straight away in here all we need to do is change the value type from digital ball to axis 2D Vector 2D like so I'll hit Ctrl s to save that like so then we can close this then what we're going to do is go back to our content browser and we can actually right click on this and duplicate it and just rename this to IA look instead now so this is going to be how we're looking on the camera and because we duplicated it we don't need to change the value type again because we've already done that now and one final time we're going to right click go to input create an input action naming this I a and then jump so we have our moving we have our looking and we have our jumping and with jump we're going to leave the value type as digital ball like so so we'll close all these like this now once you've got all your individual input actions set up we want to create a mapping context so we can actually then assign which buttons are going to do what for these input actions so if we open our content browser again we can right click go back to input and create an input mapping context I'm going to get that name this IMC and then you can name this whatever you want so default or the name of your player if it's going to be different for each player I'm just going to put my game as let's say I'm going to have one for my entire game I'm going to open it up like this then all we're going to do is add in an action mapping here add in the one we want so let's do jump first since it's at the top and then we can either choose the button from here or we can press here where we can select key value and then press the button we want so for me I want spacebar as for me obviously jump makes sense to me on space that's all we need to do for this part then we can add in another action wrapping let's do look Nexus again that's next on here and I'm going to set this to be Mouse X Y or X Y sorry 2D axis so basically we're moving our Mouse onto the axis on the X and the Y like so and that's all we need to do for it now the next one we're going to add in mapping again and we'll do I a move now this one is a little bit more complex so we obviously want to set in our buttons first for this so in the old versions We had to move forward and move back this is again different so what we're going to do is all in one so we'll get W then we'll add in another control binding to the action mapping here or we get a add another one for S and add another one for D and of course you can add in as many on here as you want so you can have wasd you can have the movement arrows you can have Gamepad controller anything you want just put on here and then this next part is where it gets a little bit more complex so we're going to open up the drop down menu for w i e for going forwards then what we're going to do on here is we want to add in a modifier and this modifier wants to be a swizzle input axis values and what this does is it basically makes it register as a y-axis instead of an x-axis and then if we open this up we can just make sure that it's set to Y X Zed it should be by default but make sure it is and again you can see swap X and y-axis like so then we can close this one and move on to a so going left we're going to add in another modifier with this one it's just going to be negate so negate there which as you can see is going to invert the input Pi axis and we open this up make sure it's x y z all ticked again should be by default that's all we're going to do for a then we're going to go down to s s is now obviously going backwards so we can add in another modifier this one is going to be Swizzle input axis values again with again being y x z and then we're going to add in another modifier on here with this one being negate once again with again the default values being x1z all ticked and that's all we need to do for S so again that's going backwards and then finally last but not least with D or going right we don't need to do anything it's by default that one will be fine so essentially if you didn't do any of this for all of these it would just be moving right the whole time so by default we go right so we need to set up all the different things on forward left and back to make sure we can actually control that perfectly how we want so now we've got our input actions and our input mapping setup for jumping moving the camera and moving the player we obviously need to set up the code flat and I'll play a blueprint as well but we can now actually control it so I'm going to save this like so and close it so next let's actually start setting up our player blueprint so go back to our content browser I'm going to go into characters and I'll right click create a blueprint class and I'm going to create a character like so as this is going to give us a lot of great default stuff we need to create our character I'm going to simply just name this player BP very inventive but we'll open that up straight away and again in here you can see we've already got our collision and our mesh and our character movement and everything that we'd want so what we're going to do is select the mesh and just give it the mesh that we want so I'm going to give it a tutorial TP EP but obviously if you have your own custom mesh animations perfect set that up like so and if you don't have your own custom ones but you do want some I do have a video which I'll leave on screen now and a link in the description down below where you can use mix mode to ue5 and then set up an animation blueprint using those animations as well so compile and save that but you'll notice we also don't have a camera in here so let's add that in now we're going to add and we're going to add a spring arm like this which is basically giving the Collision of the camera so it's not going to clip through walls and with the spring arm still selected we're going to add in a camera very simply like so it's automatically attached it to the end of the spring arm like this I'm going to move the spring arm up a little bit just give it a bit of a different look then we want to change some settings for this so what we want to do is if we select player BP self up at the top we're going to search for pawn and we want to make sure use controller rotation your is false so it's not ticked and if we go back to the spring arm what we want to do is make sure we tick use Pawn control rotation and on the camera we want to make sure use Pawn control rotation isn't ticked it should be left false by default but just make sure that it is false and something else that you may want to do in here as well is if we select the character movement and search for Orient what you can do is Tick Orient rotation to movement now this one isn't necessary for it to work but it's does make it a look a lot better so essentially what it's going to do is when you go right it will actually make the player face to the right and then go essentially forwards going to the right instead of it just kind of strafing to the right instead so obviously you can choose if you want to strafe or actually look in the direction it's going in but for me I prefer it with Orient rotation to movement on so we'll take that compile and save and that's the basics of our character Now set up for us what we want to do next is actually start setting up the movement so we're going to go to the event graph to do this code we'll delete begin overlap and event tick as we're not going to need those but we will keep event begin play what we're going to do from here is drag out and cast to player controller you should have one of these by default it should come with the project even when you create a blank one like I did and as the object what we're going to do is simply get controller not get player controller just get controller like this then out of this so as player controller what we're going to do is get enhanced input local player subsystem and this is essentially what allows us to control the player as you can see it is the input player subsystem obviously local for each individual player out of this organ going to do is simply get an is valid node with the question mark like so plug that in there is not valid we're not going to do anything and is valid we want to actually start using this mapping context which we just created so the reason we're getting the is valid is because if this doesn't exist if it isn't valid then we don't want to try and add something to it but it should always be valid but it's always again good to have this just in case because otherwise you'll get an error and it won't work so out of the enhanced input local player subsystem what we're going to do is add mapping context so we want this one here connecting that into is valid now the mapping context is going to be the one we just created so I need mine IMC my game like so let me just double click this get some rewrite nodes like so now you can obviously change the options then priority and all this stuff if you wanted to but I'm not going to be going over that today but you can see what we've now got is this player blueprint which we've just set up is now going to be using the input mapping context we just created so this player can now move forward backwards left and right they can move their camera and they can jump obviously we haven't set up actually controlling those yet but they now have the ability to do that so we can compile save that and actually start setting all this up now so if we find some empty space we can right click and let's search for IA and we'll do jump first as it's the easiest so get IA jump now you can get this without the mapping context being added however it won't work when you come to play the game so again IA jump is very easy to do we're going to come off of triggered and get jump which is a function you should have by default with the character blueprint and completed is going to be stop jumping it's as simple as that so we've got jump and stop jumping like this so let me select this hit C to comment it and I'm going to name this one jump nice and simple like this and next let's do the camera input so we'll go underneath this right click get IA look I named mine so we get that there and what we're going to do without this is out of triggered we're going to get add controller your input and after this we're going to get add controller pitch input so the yield is obviously going to be left and right and the pitch is going to be up and down so now what do we put in the values for this because again in the old system we used to just have the input axis values on our events which we obviously don't have now but because when we created our impact action we created it as a vector 2D what we now have is this action value if we right click it and split the structure pin we have the X and Y or what I should say sorry is the action value is the vector 2D whereas if we go to jump the action value is a Boolean as that's what we left as so if we right click our action value split the structure pin we now have the X and Y values X going into your and Y going into pitch as again the x is going to be left and right the U is going to be up and down other y sorry it's going to be up and down so we can now select this hit C to commit it and we've got our camera inputs or our camera controls like so and finally last but not least let's set up the movement input so we'll right click again I a move we'll get this in here like so and this is again going to be coming out of triggered so let's just drag all the way out and get add movement input now this is going to be very similar to how we did it in the old versions as well what we're going to do is right click get control rotation we'll right click the return value and split structure pin so we have access to X Y and Z values individually then what we're going to do is right click and we want to get right Vector like so right click that and split the short spin once again collecting in the X to the X and the Z to the Z but leaving out the Y and then the return value of this will go into the wild direction of the add movement input again that is the same as it was in the older versions it's just the input going into it is slightly different now so this one is obviously going from left and right as we're getting the right Vector of it with the X and the set like so now the scale value of this is again going to be the same thing we did with the camera input so we'll right click the action value split the structure pin and the x is going to go into the scale value of this so again in the old versions it was our axis value now it is our action value very similar but obviously I hope you can understand the differences then forwarding back is going to be very similar again the same as it was in the older versions what we can do is we can actually just copy and paste all this here connect it in and all we're going to do now is change the control rotation and the get right Vector slightly so we'll actually delete get right Vector right click and instead get forward Vector like so just get forward Vector there splitting the stretch pin of the in rotation this time just setting it to Z into Z like this and the return value into world's Direction and the scale value of this one is obviously going to be the Y of our input action instead of the X and I'll double click this to get some root note once again just to keep it looking nice and organized like so and I'll move this over and there we have it we now have our movement input as well so if I select this hit seed to comment it I'll name this movement input I'll just move all this up like so and that is pretty much all we need to do for it what we've done is we've set it up so we're going to be using the correct action mappings and action values and input actions inside of our player blueprint and then we're setting up using those so we can jump we can move the camera and we can move the player we'll compile and save that and we're going to close this as well and again that is now it done working for us now if you've done what I've done and you've created a blank project you're going to also need to make a game mode that's just so we can spawn in the player if you've already got all that set up you can spawn in the player and all that great stuff you can ignore this part but it's very quick and simple to do all we're going to do is go into our content browser right click go to blueprint class open the drop down menu for all classes and search for game mode and we're going to get just normal game mode there and hit select I'm gonna name this my game game mode just because that's the best thing I can think of right now and we don't even need to open it we don't need to do anything with that all we need to do is go to world settings over the right here and if you don't have the world settings go to the top right where you see settings and just press World settings and it should give it to you and take you there as well then in here you should see game mode override just set that to the game mode we just created so I need mine my game game mode and then the default Pawn class we're going to set to our character so for me that's player BP now when we press play We Should spawn in with our character and we can see that we can move the camera we can jump and we can move forwards backward words left and right and again you can see it's rotating the player character to be where we're moving to so this works perfectly for us so I think that'll be it for this video as we've done everything we want to do what we've done is we've set up our own character movement so we can move forwards backwards left and right as well as moving the camera and jumping as well so thanks so much for watching this video I hope you enjoyed it and hope you found it helpful and if you did please do make sure to like subscribe down below as it really does help me in the channel out a lot so again thanks so much for watching this video and I'll see you all in the next one okay [Music]
Info
Channel: Matt Aspland
Views: 46,570
Rating: undefined out of 5
Keywords: ue4, unreal engine 4, unreal engine, tutorial, ue4 tutorial, unreal engine 4 tutorial, how to make a game, how to, blender, unity, games design, ue5, unreal engine 5, unreal engine 5 tutorial, ue5 tutorial, enhanced, input, action, mappings, mapping, system, axis, ue5 enhanced action mapping, ue5.1, 5.1, new, enhanced input, plugin, how to use, movement, character, creating, scratch
Id: Z9zEEY7dGaM
Channel Id: undefined
Length: 16min 42sec (1002 seconds)
Published: Tue Dec 06 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.