UE5 Tutorial | Create Movable Player Character From Scratch (Blueprints)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] greetings and welcome to a brand new unveil engine 5 tutorial it's a new era and unwell engine 5 has released a good while ago actually for as early access and i'm going to remake one of my most popular unreal engine 4 tutorial which is how to create a player character from scratch with blueprints so we're just gonna launch the engine and it's important that you do exactly what i do in the steps that i do them to make sure that you're not doing something i'm not doing or not doing something i am doing and thereby getting a result which isn't the same result as i get so please make sure you do exactly what i do so we're going to start entirely from scratch with nothing else than a blank project and if starter content is checked then uncheck that as well and make sure you save the project where you want to have it and we will name the project my first player or you know my first character yeah so create now i know i have a version of the engine that is crashing when i press play so the first thing i'm going to do is go up to edit and project settings and search for motion and remove motion blur because for some reason that crashes the engine so i'm just going to make sure it works yes all right so the first thing we will do is delete everything so we delete the light source yes we delete the atmospheric fog delete the skylight delete the spare reflection capture we delete the sky sphere and delete the player start only the floor should remain now with the floor remaining right click on the floor and place one single actor a directional light so we're just going to move it up a bit and with it selected i'm gonna take the intensity down a little bit so set it down to three and i'm gonna make the light a little bit more evening like because i think blue is a nice color there that's our level now we can save so ctrl no before we save build actually before we build select the floor and under transform take scale and just make the floor a little bit larger so three three three because then the player character to be will have more space to run around on now we can build so go up to build and simply take build all levels there we go now we save i'm going to call it my player level zero one next thing now is we open the content drawer by pressing ctrl and space and this is a new thing because we used to have the contents just docked in the layout we can still do it but i think actually it's nice to have just a drawer that you can whip up and down so inside here we will right click and we will create a blueprint class and it should be a game mode base and we will call it my game mode next we right click again and we select blueprint class again and this time we will create a character we will call it inventively enough my character now we select both of these and we just ctrl and s to save so before doing anything else let us set up the input bindings the actual keys we will use to play with the character so we go to edit and project settings and we go to engine and down to input now for a very basic character what's the least amount of functionality it must have it's walking backwards and forwards left and right strafing left and right and it's rotating left and right looking up and down right but we're going to take it a little bit further than that so we're going to add jumping and running and crouching then we will have a really good starting point for our character so we start by clicking access mappings adding one and the first one will be forward and backwards so we're going to say forward underscore backward click enter and we're going to play with was so the first one will be w so keyboard w add another one and it should be s you can just click s and then scroll down and it will be a little bit easier to find now these both have the same scale right now so that means if we don't do anything else they will both go in the same direction so we need to reverse the one that will be backwards therefore we will set a minus on the s and let's keep on going so we will take the strafe so we will call this strafe underscore left underscore right and that will be a a search for a and then pick the a and add another one and that will be d not s but d and again they have the same scale so they will move in the same direction so to reverse one of them we will take minus in front of the a i don't remember if that's the right one but if it's wrong we'll just revisit it and you know put the minus on the d instead so now we got forward backward left and right next is to set up the mouse so we will add more axis mappings and we will call this rotate left underscore right and this will then be mouse and it's left and right so it is on the x-axis we add another one and we will call that look up down and that will then be on the y axis y x right and again they have the same scales we need to reverse one of them i think maybe that's the y if not we'll just go back and fix it later so let's now set up jump then we go to the action mappings and we'll call it jump and this will be done with the space bar so we can just write space and choose space bar add another one and call that run and that will be left shift so we can just right left shift and the last one will be crouch crouch and we can put that on the c key so that should be it for now so now we can just save always save save like a maniac because you never know when the when the engine will just crash and die so with this setup we can open our character i'll just place this tab and dock it up here now if you get a screen with just a bunch of text and stuff then just click the blue little link in the top somewhere that tells you it will open the full editor or something like that and then we can go into the event graph and since we're starting from scratch we can just take all of these and delete them so now we're gonna get the forward backward so we right click and we simply search for forward and we will take the forward backward axis events not the axis values so we click on the axis events right there and then we drag this out and we will take get movement i mean add movement input and it wonders what the scale value will be and as you remember we have already set the scale value so we can simply drag the axis value out and connect it to the scale value and it needs to know the world direction and we do that by searching for get actor forward vector like that now let's set up the strafing so we right click and we can just search for strafe and again we will take the axis events and not the values and this time we can just copy this so ctrl c ctrl v connect and again we can connect the axis value to the scale value this time though on the world direction we will take get right vector no that's not right well it was right but not the right right right get actor right vector there we go and just to make it look nicer we will select all of them and press c for a comment and just explain what these do so walk forward and backward strafe left and right and we can give it a little color if we want that and i want that now with this setup we can compile and save and this won't work but let's try to play anyway just to see it just to make sure we have done it so we press play and what happens is that you're just this disembodied floating flying thing right so you can't do anything right now and that's perfectly fine so in order to fix that we need to go back into our level and open our drawer and we drag our player character into the scene and to make sure that we actually force the game to use that character maybe it works already but i'm known people getting so many different errors that we're going to make absolutely sure all the holes in the buckets are filled or fixed so to speak so the first thing we will do is go to the settings up here to the right choose world settings and we have the game mode here so game mode override select and we will use my game mode and under here we have the selected game mode default pawn class here and this is important you will choose the character we're working on now which is my character next is we select our player my character and we go to details and in the search details we can search for pawn and under pawn we have auto possess player and we select player zero now this might not be necessary but i have known cases where this has been necessary so that's why we're doing it now though we save the game and we try to play and here we are and if you set up the bindings correctly you will be able to go back and forth and strafe and they will be in the right directions if experiencing it going to the right when you press left and vice versa for the forward and backward then just go into the input bindings and change who has the minus in front of it but this is all good so then we have a player character that works now we can go back to my character and we can set up the my the mouse bindings so right click and search for rotate and again we're going to have the axis events rotate left right so we drag this out and we search you can just search for y'all no maybe not and controller your inputs like this and the axis value will be connected to the value here like that and for looking up and down we simply right click and we search for up down up down there we have look up down and this time we drag this up out and we can search for and controller pitch input pitches up and down and again connect the axis value to the value on that node and we can select all of these and create a comment rotate left and right look up and down and give it a little color like so and we will compile and save and save and test it and i'm now able to walk and look with the mouse up and down and everything is correct so if you're having something turning the wrong way then just go into the input bindings and fix fix it with the minus on the right place right now it will start being fun because now we will set up the jump so we right click and we simply search for jump and we then have the action events jump and this is actually so easy that you just drag this out and you just search jump and you just take the jump right and it's important that if you do not take anything on the release it will just keep moving upwards forever so you want it to stop jumping when you release the spacebar and so you drag out the release node and you start to jump again and you just take stop jumping now if we try this it will now work you will be able to jump but you'll only be able to jump this high that's the only thing and i want to make sure we can do a little bit more with it i want to be able to jump as far as i want to jump and i want that number to be able uh to be changed so what we can do is create a variable so we go down to variables and we just create one that we call jump height and we change it to float that's just a simple number so we compile to make that editable and with jump height heights selected here the details for it shows up here and and we have jump height on the default value here now this isn't actually how high the character can jump but rather the seconds that it will be going upward and so if we take for two seconds it means that we can hold the space bar in and after two seconds it will start going down again and that way we can manipulate how long how high you can jump by increasing that number of seconds right if you set it for 10 seconds you will be able to jump for 10 seconds so take this variable and drag it out here and set it and nope i mean get it and we can drag out here and you can search for jump max hold time now if you want to just pick this out and put it there you can hold in control and then put it like so now and you can hold alt in to disconnect the node like we could just take set here and it exists because it's something that already exists and we could say here that we could set it to file you know and it would already be done but it's better to create a variable variable because it has more uses so with a variable we can now manipulate the variable and do things with it we can talk more about that a little later but for now let's just check that it works so we compile and we save and we play and we hold the space bar in and we see that we are floating upwards for two seconds and that also means that whenever we let go of the space bar we start going downward so we can jump as high we want but not higher than so high we're getting in two seconds yeah of course so that's the jump comment jump and we'll set that to be red because super mario jumps right now let us set up well first let's save now let's set up running so we right click and we just search for one or maybe we should start for action and then one action events run so to know what will be running and what will be walking we can first check what is the normal walking speed of the character and by doing that and or yeah you do that by going to my character here on the left and going down to character movements and in the details you can search for walk and then you see that you have max walk speed 600 so then we know that okay walk the regular walk speed is 600 so now we can create our own walk speed which will be the run speed and we will do that as a variable so we will call that run speed it will be a float we compile make it available here and since walking is 600 we can say running is twice as much so that's 1200. so we can drag out input action and set max max walk if this doesn't show then just uncheck the context sensitive and you have the set max walk speed here and again you could set the walk speed here but instead it's better with the variable because we can do more with it so we just drag that in and set it no again we don't set it we get it and connect it here and this one needs a target because who's doing the walking who's doing the running obviously it's our character and it's the character movement that does the movement so you can hold ctrl down and drag this in to get this and then you just plop that in there so if we now compile and save and try the game we click shift and it starts running but it keeps on running even when we let go of the shift and that's because we haven't put anything on released yet so we take released and we then set next walk speed again and we set that back to 600 which is the default and we connect the target again to our player movement now if we compile and save we will run and then stop running when we let go of the shift and we can jump and look and strafe and yes so that's cool so that's running select all comments and we just call it one and this bubble will be blue because sonic runs hella fast and i'm just compiling and saving everything now last but not least we will make our character crouch so right click and just search for crouch [Music] and we have the action events crouch which is what was set up and this is easy you just take out the press and you search for crouch and you just select the blue f crouch and again on released you search for crouch and you select the on crouch but even if you compile this it won't work because what you need to do first is again go to the character movement and in the details you search for crouch and here you see that under nav movements you have to enable can crouch there and here we can see that the crouched half height is 40 which means you can change this to a lower number for example if you want the player to be able to crouch even lower but this is fine for us now so now we can compile and save and save and test it so when i click c i crouch and i pop back up when i let go and although i saw that the crouched walking speed is 300 we know that the normal walking speed is 600 so he's crouching half the speed but i still think that's a little quick so i want my character to be even slower when he's crouching so i can change that here and that will fix it but i want the level designer or myself later to be able to fix it easily without having to go in here which is the reason why we're creating variables so we're going to create a new variable called crouch speed and compile it and under the default value of crouch speed we will set it to 150 and then we will grab the crouch speed and drag it in and we will get it and then we can drag this node out and we can search for set max ground walk yeah set max walk speed crouched i will connect that to that one and we must make sure that the target is the character movements so we hold down the ctrl key and drag the character movement in and connect it to that one and of course connect this again like this and select all comments and call it crouch and now compile and save and let's see if the character works and if it's crouching and walking really slowly and it does now the reason we have created variables because now you see this little i symbol if we open this i we're making the variables public you might know this you might not if you not know it if you don't know it then this is very valuable by making the variables public they can be manipulated out in in the not the browser but yeah in the main engine main engine window so we make them public and we compile and save and if we now go out here and select our character we will see that under default we have the character selected and under default here are our variables jump pate run speed crowd speed so now it's really easy for yourself or the one designing the level to change how high the level can jump or how fast he can run or whatever depending on the obstacles that the level designer chooses to put up so now we can easily make the player run now jump for five seconds and run in supersonic speed and crouch in super duper slow speed you know and then play and we can see that i'm running crazy fast i'm crouching so slow it seems like i'm always standing almost standing still and i can jump so high it's like i'm flying you know so it's really easy to change things when you create variables like that and there you go a fully playable character well at least the function the mechanical part of it so hopefully that was helpful and have a great day [Music]
Info
Channel: Ben Ormstad
Views: 85,418
Rating: undefined out of 5
Keywords: unreal engine 5, ue5, unreal engine 5 tutorial, ue5 tutorial, player character, character, controllable character, create a custom playable character, tutorial, how to, player, input, key mappings, input mapping, movable character ue4, player crouch, player run, player sprint, character crouch, character run, character sprint, character jump, basic character movement setup, basic player movement, game character
Id: Tf4rpJfOy54
Channel Id: undefined
Length: 32min 35sec (1955 seconds)
Published: Wed Dec 01 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.