Unreal Engine 4 Tutorial for Beginners - Lets Make a 3D Platformer

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey everyone welcome to my unreal engine 4.26 beginners tutorial using this unreal engine hour of code project it just came out so you're going to want to go to the marketplace here and you can either search hour of code or you can go to the epic games content here under free and it pops up right here so it just came out and i think this is a pretty cool project for learning unreal engine so if you're brand new this is your first time ever using unreal engine then go ahead and create this project and i'm using 4.26 but it will also work on 4.25 and this project is really designed for like teachers to be teaching students almost in a classroom setting they have lesson plans and everything and there's five lessons total so what we're going to do is i'm just going to go through each lesson and do them on the video and you can kind of do them with me and and you're going to learn the basics of unreal engine and hopefully have a decent understanding of how to make games with it so once you create the project it's going to end up in your library up here and it will be under your my projects so here's what it looks like for me so you're just going to want to double click this and open it up so here's what the project looks like when you first launch it you can come up to the top here hit the play button and now you're able to play and run around you can hold down the shift key and sprint but yeah this is just a very basic third person character they have for you and you can try to cross this gap but now you cannot and that's actually lesson number one so so the first thing to learn the first lesson is just about collision how collision works why we use collision in video games and how to do it in unreal engine 4. so this is actually the pdf for the first lesson that you can download if you want but this is really for for the teachers right and it kind of just goes over collision and things like that overlaps why we use them but here's the activity that we're supposed to do in the first lesson we basically want to get the player across this gap and then get the player over here see activity one this is like the end point of the first lesson so first how are we going to get the player from the starting location here over to here so that's the first lesson and so this lesson is really meant to get the beginner the the first time user comfortable with the engine here so you can grab these meshes in the level you can move them with this gizmo here and then if you press the e key that lets you rotate you press the r key that lets you scale and then control z to undo and then the w key to move back so w e r these are good shortcuts to get used to and then up here you have snapping so as you can see when i move this it kind of snaps if i bump this up to like 500 it's going to really snap around so these things are pretty important for you know building out your levels but you can always turn off the snapping with that button there and then just move it as you wish and then same with rotating if you press e it's rotating snapped but there will be times when you want to click this and disable snapping and have smooth rotation and then scaling as well you can always un snap the scaling here and then scale as you would want to so let's say you want to place another box in the level or actually in our case we got to make these platforms that the player can cross right but the issue right now is the player if he even steps on it he falls through it so it's like oh my gosh what the heck and that's really the first lesson about collision and actually i'm going to move this out a little bit because i don't want it in the wall here so i'm just going to move it so how do we get more of these so there's several ways you can do this i'm going to show you the long way and then i'll show you the instant way basically so over here in the world outliner anything you click on here is called an actor you can see it says 855 actors everything in your level is considered an actor this light this player's starting location this is where the player starts so you can put this wherever you want the player to start the game so i'm gonna have him start back here now by this window and he'll be facing this or maybe you want the player to start down here and if i press the n key drops it to the ground and then let's rotate this 90 degrees because wherever this blue arrow is facing is the direction the player will face when he starts as you can see here so let's just have the player start down here that's fine with me so how to place more of these platforms we need the player to get across this gap here and to end up on this platform so how do we do that well if you click on the platform you can see it selects it here in the outliner and then down here in details it actually shows us which mesh we're using and if you click this magnifying glass it'll actually take you right to the mesh in the content browser here so this content browser is where all of your stuff is stored all of your meshes and templates and assets things like that anything you add from the marketplace it's going to show up here in a new folder and you can just kind of go through here and see what you have all these different blueprints different meshes textures widgets etc and what's really cool is let's say you're looking for a specific mesh you can just come to the base of the content folder and then type in the name up here so for example this is a platform right so i can come up here and just type in platform and then it shows us different assets for platforms and we got like these four different platforms and a pretty cool tip is let's say you wanted to replace this like let's say we wanted to use this platform instead of the one we have like this one looks more gold i guess i could just come in here and hit this arrow and it will replace it i didn't really notice the difference there though maybe these platforms are exactly the same but let's let me give you another example let's say we want to put a box here right i can select that box and then hit this arrow whoa it just added a massive box right so that's something you could do if you want but generally speaking you're going to want to just grab it and then drag it into the world like that okay then you have a new box in your level now that's what i would do if you're trying to add a different mesh like a new one but once you already have the mesh in your level like i have this box right it would be really inconvenient to have to click this magnifying glass and keep dropping them into the world so instead what you can do is with the mesh selected or any object even a light you can hold down the alt key and then drag and then just makes a duplicate so that's really how you move around actors and get them in your level once you've added the actor into your level you never have to go back into the content browser and re-add it you can just select like this roof hold down alt and then drag it rotate and then you can see how i could start making like a new roof here if i wanted to to do something like that and then i could just keep going right something like that i'll just leave these here i'm not going to build out this roof i'm just kind of showing you i'll do drag and place actors so these rocks here maybe i want to add another rock over here hold down the alt key let's scale this one down make it smaller and yeah there you go you get you get the idea but anyway let's get back to lesson one so lesson one is getting the player across this gap but as you already saw when the player jumps onto the platform he just falls through it oh no he didn't so i'm going to set this platform back to the original one it's not the underscore a it's just this one and that's part of the lesson if you keep it as a it's going to have collision working the lesson for this platform is that the original one here doesn't have collision so you just fall through it so the lesson is to teach collision here so if you have a mesh in your level that the player is just moving through it's not blocking the player anything like that then that usually indicates that the mesh doesn't have collision setup so what you want to do in our case here we're going to select the platform double-click this static mesh it's going to open up the mesh editor and i'm just going to grab the tab here and then now i can click this collision drop down and check simple collision and it doesn't show anything which means there's no collision so we have to make collision so i can come up to the collision tab and then do 18 maybe something like that yeah you can do that if you want it's just a very simple collision for the platform and then what we can do down here is scroll down and then here's collision settings we can set the collision here to block all which means it'll just block the player or you could do overlap all which is overlapping and overlapping is good for doing events and stuff like if the player overlaps a certain object let's let's like fire an event right let's like print something on the screen damage the player whatever things like that open doors that's what you use overlapping for and we'll get into that later but block all means it's just going to block everything whether it's the player bullets projectiles spells things like that right but you can see there's different settings here maybe you only want the collision to overlap only pawn so it'll only overlap like the player and stuff like that so lots of different settings here but let's just keep it as block all save it and now when i play i can stand on the platform okay so obviously we need more platforms so now you get to use your new alt key shortcut and just make a bunch of platforms here and make a gap so that the player has to actually like jump now hold down alt again drag it out and then one more time so this now brings us to our second task in this first lesson so the player is jumping and then the player makes it here right but let's say the player jumps and then misses and falls down here now he's stuck here forever so in the editor you can just press the escape key and stop playing but like let's say you packaged up this game you shipped it out and then people started falling in this gap and then they just don't know what to do they have to like alt f4 to close the game so we need to set up a collision box down here that restarts the game right sends the player back to the beginning and in that case we want to use one of those overlap collision volumes because we don't want to block the player we just want the player to overlap with the box and then reset the game so in that case if you come up to place actors up here you have all these different things you can place right you can just drag these things into the level drag the player start here you can drag lights for example let's say we put a light down here let's make maybe make the color red you know like oh no warning don't fall down here i don't know whatever i'm just kind of showing you guys stuff i can hold down the alt key and just start dragging it around as well like that we want a volume down here a collision volume that's going to reset the game so in that case you can type up pain you get this pain causing volume so let's drag this into the level it just looks like a cube like this so what we want to do is actually scale it up so it's about the size of this gap so i'm going to press the r key and just start scaling it then press r again let me come out here and press r and start scaling it again it's kind of hard to scale it in this thing actually but let's just scale it and then bring it down so it's the size of it but i'm going to bring it down so that it's about halfway down or at the bottom or something so it's kind of like lava right the player touches it player dies and so we want to reset their location but i got to make sure it's covering the whole thing i don't want it off the not covering that edge completely so there we go let's bring it in a little bit more okay so it's covering everything and so now when we play the player is jumping and if the player falls in oh no he restarts yay so that's just a quick lesson there on overlapping you can do a lot more with collision and overlapping and stuff like that but we'll get into it later so now to finish up the first lesson or the first activity once the player reaches this location the player's got to get to here and so now for you as the developer you just got to kind of figure out how you want the player to get there so in our case what we can do is just grab these platforms and just hold down alt and then just start moving them into position here the player can just start to jump across right so that's all you have to do just start placing these floating islands around and place enough so the player can get to the destination i'm just gonna do that really quickly do something like that like that and then like that and jump across the gap here wow such a good gamer oh no and then yeah you can hold down the shift key and sprint and boom we made it activity one complete but what if the player falls off here right you jump off and you're gonna fall forever you'll just never stop falling and here's another cool lesson so i hit escape key and now the camera is stuck down here so let's say i had nothing selected i can't see any of the world up there i'm just way down here i don't know what's going on what i can do is in the world outliner i can type in player start right here's the player start i'm going to select it and then in the world here in the viewport i'm going to press f and it's going to take me to the player start so any actor you select when you press the f key it'll take you to it well that's like a weird fog plane i think no that's a i don't know what that is anyway i can select the cloud press f so yeah you get the idea there so how do we fix that issue though if the player falls off so in the world settings here we have this kill z and to make this work you have to click this arrow show advanced and then enable this and so when the player reaches this negative whatever location that's where it will reset the player so what i'm going to do actually is let's just grab this guy and i'm going to move him down to a location where we want to reset actually this is a good location to reset so that location is negative thirty three thousand eight hundred so i'm just gonna do minus four thousand and now i'm just going to go test okay i stuck in my own game so i'm just gonna jump off and see if that works so fall to about minus four thousand there you go so now let's move on to lesson number two so lesson number two is about moving platforms and checkpoints and so what we're gonna do is here's the activity one at destination so if you come to the content browser here in the hour of code folder go to blueprints and they have this checkpoint blueprint that they've created so just take this and drag it in here and this is kind of like a little checkpoint spot so once the player crosses the platforms gets to the other side and this is like what the player is looking for we can make it bigger right we could like scale it up it's up to you but this is what's called a blueprint and so if we double click this and open it this is where you're going to do your programming so on the left you have these components that you can add and this blueprint has a cylinder mesh a button ring mesh so i can like move that it's separate it's got a collision sphere a checkpoint transform checkpoint text and then an arrow so anytime you make a change to a blueprint like let's say i move it up here i would click this compile button to save it and then in the event graph here this is where you actually do your programming so this is the code that they've set up for the checkpoint so you just go left to right here this overlap that's kind of what i was talking about earlier so when you have collision components if you scroll down here on the details you have all these different events that you can do when the collision is hit by a player so the most common one is this begin overlap you can see they've already added it i can click view and it'll take me to it basically this event fires when whenever an actor overlaps the collision but that also has to be based on the collision settings right so the collision here is preset to overlap all dynamic this was set to overlap only pawn for example this would only fire if a pawn which is you know the player's character overlapped it now if you don't want to use a preset you can always go up here and click custom and now you can actually customize the collision here like let's say we want it to ignore everything except for just pawn which means the player this is actually really common i do this all the time like i want it to ignore everyone only overlap with the player ignore like bullets ignore you know rockets fire things like that right so i'm actually i'll just keep it like this because the player is the only thing in the level so i'll just keep that and then the collision enabled you can either set it to have no collision or query only which means you know just like overlapping but then you can also do physics and collision enable and things like that so in this world here there's this ball the player can actually kick this ball around so if i drag this out make a duplicate here let's put it right there when i play the player can actually kick the ball around kind of cool and the reason for that is i click the details here number one the ball has physics enabled and then number two the preset here is physics actor and then it's object type is a physics body so it's able to be pushed around you can see how it's supposed to block everything so that just kind of gives you an idea of how the collision works for certain objects now this box here this isn't a physics actor it doesn't have physics enabled it's just designed to block the player not get like pushed around or anything like that but let's say let me bring this box out here let's scale it down now if i put it up here and i go to simulate it's just going to float see how it floats so simulating is pretty cool just to see how you know the world responds when it starts so if i hit simulate again this ball falls because it has physics enabled whereas this box is floating so if i turn on physics here and then simulate should fall yeah you can see how it falls and then if i make this box a physics actor which it now is i'm going to play the box falls and now i can kick the box around we okay but let's update our game a bit so we're on lesson two okay so let's go back here to the blueprint so the player hits the checkpoint it's gonna it's basically this red sphere that you see here this is that overlap so when the player hits this red collision sphere it's gonna fire this event okay it's not actually the mesh here that's firing the mesh is just for like appearances it's actually this invisible red sphere circle that fires this event and runs the logic so what happens is the player hits the sphere this variable called checkpoint enabled it gets set to true the checkpoint gets activated and then this means it's going to change the color of the checkpoint to this blue right here so you can like change this to whatever you want and this dynamic material reference it's like where did that come from basically what happened is they created a variable for it this is kind of advanced but if you come up to the construction script this gets ran like whenever the object is in the world and all they're doing basically is creating a variable off of the material that is being used in either the cylinder or the button here i'm not sure which one and then they're able to make it into a variable as you can see right here and then they're able to update the color because of that so kind of advanced but yeah anyway after it runs this it's now going to set the spawn location to this new checkpoint that's what's going on here it's casting to the game mode and then setting the new spawn location and then all this does is play a sound just play sound 2d you just right click play sound 2d or maybe you want to play sound at location then you could do that but then it's going to ask you for a location so how would you spawn the sound at the location in that case let's say we wanted to spawn the sound right here on this object all you would do is you'd right click and type in well i would just start with location if you're new right you type in location you're like okay what am i looking for here there's a lot of stuff but what you would actually be looking for is this one called get actor location this will just get the location of this specific actor in the world so if you click details and come up it has this location that's all it's getting it's just gonna grab that location and then we plug it in here because if we keep this blank then it will actually spawn a sound at zero zero zero so let's say i grab this rock here i'm just gonna duplicate it i'm going to set its location to 0 0 0. so that's right there this is 0 0 0. so if i keep this location blank when the player steps on this checkpoint it will literally spawn a sound right here at zero zero zero it'll play a sound right here so we don't want that what we do want is to play a sound at the actual location of this blueprint wherever it is in the level so instead of playing a 2d sound i'm going to hold down control and drag this pin here so now we're playing a sound at this new location but it needs a sound file so cool shortcut is i can click this magnifying glass right here takes us to this sound effect i can pick any other one if i want but let's just select that and then come back here click the arrow boom now we're going to spawn this sound at location instead of playing a 2d sound so just a cool little intro to blueprint you can also click this drop down button gives you more options here but yeah so anyway now when i play the players gonna have to cross all the stuff he created here and then as the player approaches the checkpoint he hits it plays the sound at location and updates the color to blue now when i play you notice that i start back here again we don't want that you might be thinking like hey i thought we were adjusting the new spawn point i thought we were updating it so this is another lesson here we're setting the new spawn location to the transform of the checkpoint that's what's going on here and the transform if you're curious that's basically the location the rotation and the scale just all combined into one variable so an example here is if i duplicate that i can duplicate anything in blueprint with control w very handy shortcut and if i right click this pin i can click split and so now we have the location rotation and scale so you'll find yourself splitting transforms at times and then just working with one thing at a time i could actually take this and plug it in there if i wanted to right because it's both they're both yellow which means they're both vectors and they're both the locations of the actor but anyway we're supposed to be updating the spawn location of the third person game mode so how do we find the game mode here well if you come into the level and then click world settings here's the game mode override third person game mode so this is the the rules and stuff like that for each level every level you make you're usually going to plug in a game mode here by default it will say none so then you'll get your game mode and you'll plug it in so let's click the magnifying glass and browse to it and then let's open it so let's come here and then on the left we have this variable spawn location now let's say you have a lot of code here and you don't know where this variable is being used you can right click and do find references and then it's going to show you all the locations so i can like double click this takes me here and then set spawn location here so if you're seeing all this and this is like a foreign language to you i'll explain what's going on here as simple as i can so there is this function called get game mode you can right click and type in get game mode and it'll pop up and then what we're doing with the game mode here is we're casting to the third person game modes we're basically getting a reference to the game mode in the world here remember it's called the third person game mode so what we're essentially saying here is when the player hits the checkpoint the player hits this red sphere here this invisible sphere the player hits it in the world this event is going to fire and then when it gets to this point in the code the checkpoint itself is saying hey i want to talk to the game mode and i want to do something with it and in this particular instance what i want to do is in the game mode there's a variable called spawn location it's right here it's a it's got this orange color which means it's a transform you can see up here it says variable type transform so what the checkpoint is saying is that when the player hits it i want to talk to the game mode and i want to tell it to update this new spawn location so throughout your world you might have a checkpoint here and then you'll have checkpoints like all over the place maybe here if you have one here each time the player hits a new checkpoint let's tell the game mode to update the new spawn location and the spawn location is used when the player dies so this is like the respawning functionality here so the player jumps off an island falls down and then the game respawns the player that's what this spawn actor right here is so this spawn actor it can spawn any actors you want any blueprint actors so if i click this browse it's just going to spawn the player character again it's going to respawn them and it's going to spawn them at this transform so it's asking for a location basically and what we're doing is we're taking this new location we're sending that to the game mode and we're going to spawn the player in that new location so in this particular instance if the player falls off here he's going to respawn right here on top of this checkpoint so that's what these two things are here so to actually get this variable here this variable is the spawn location here in the game mode so to actually access that you would drag off of here now just type in spawn location and then you have get spawn location set spawn location what we did here is we're setting it because we want to set it to a new value so that's all we did here and then this new value here that's this stuff here this checkpoint transform this variable is this guy up here in the left it's called this checkpoint transform this paper sprite component so in the viewport you can't really see it there's there's really nothing here it's this guy here it's just there's nothing set for it so there's just nothing to see it's basically an invisible object but this is the component we're using to spawn the player at and so what's going on here is that you can take these components here and drag them into the blueprint editor like that and then you can do stuff with them so in this particular case we're just getting the transform so you remember we got the actor location of this whole entire blueprint that's what this is but in this particular case we are getting the transform of just this component so right here get world transform we're grabbing the transform of this component here in the world so you can see i can actually select these things here and if i want to i can move them see i could actually put that there if i wanted to but i don't want to do that so this code here is getting the world transform of this checkpoint transform right here so whatever this transform is we are taking that and we're now sending it into the game mode and setting the spawn location right here so we're updating this variable that is what's going on in this whole section right here this part okay so kind of confusing but try to explain that as best as possible just to help you kind of understand what's going on what i'm going to do is i'm going to play i'm going to go hit the checkpoint over here i failed because i suck anyway let's just not suck this time so i'm gonna hit the checkpoint and now i'm gonna kill myself and i think i should spawn here at the blue yeah see so i spawn at the blue and i'm huge what the heck is going on why am i so massive so what happened in the size here this is actually a cool lesson is remember how i said the transform has all three of these things here so you can see it says transform has a location rotation and scale so what actually happened here is when the player hits this checkpoint we set that as the transform we take the transform of the checkpoint and we set that to be the spawn location but this is actually i don't think this is the right way to do it because what happened here is i scaled this up to 1.8 and so what happened is we're actually setting that as the transform of the player so you can see here spawn actor epic character that's like our character here you can open this up and just look at the guy that's who we play very simple code here just movement and mouse and whenever you make a project epic comes with like a default character and it'll have most of the stuff here it won't have death or sprint or anything like that but we can get to that later point being is that the player gets respawned with this transform here so it's actually responding with a scale of 1.8 so if i bring this into the level the player starts he has a scale of 1.0 right just default that's fine but he's respawning with a scale of 1.8 so it only scaled on the x i'm going to click this yellow arrow resets it and then i'm going to click the lock mechanism here that makes that makes it so anything i enter here gets applied to all three so i'll do 1.8 so this is how he respawned he respond like this right that's what i respond as with a scale of 1.8 because that's what this scale is 1.8 so i could set this back to 1.0 and then the player will now respond with a scale of 1.0 but what if you want this to be big right you want this to be big but you don't want the player to spawn with that scale so what you would do then is in the third person game mode here these are transformed so i can hold down alt and click separate them and then i can right click i can split it and then right click this and split it so maybe we only care about the location and the rotation but we don't want to plug in the scale because the scale is now 2 we want to keep it as a 1. 1.0 okay so i'm going to compile and save and this is in the game mode and now i'm going to play and try not to die on my own level which is embarrassing so i get here i hit the checkpoint now i'm going to kill myself and i'll spawn with a scale of one so just normal size there we go okay cool so now we have this moving platform thing going on so what i'm gonna do now because i don't wanna keep playing level one or activity one or whatever so i'm just gonna delete our player start and then now right here in place actors i'm just going to type in player we get player start and i'm just going to drag it right here so now when we play we're just gonna start here now but now this next activity is about moving platforms so i can jump on this get to the other side and then now we gotta somehow get up to that island over there but we want to make our own moving platforms so it gives you a little hint here with this level sequence so we're going to be using the sequence editor but this is the sequence for our moving platform right here so they've already set this up for us and then we're going to make our own so you can see with the sequence here it's set to auto play and then loop indefinitely so let's say we set this play rate to 5 and now we play and now this thing is just moving really fast look at that oh and get me on there uh-huh i'm good oh i'm bad but yeah so let's set this back to one that just gives you a little idea there and now we gotta make another one or our own to get over here actually let's just double click this platform level this level sequence you can double click it and down in the bottom here at least for me it opened up this sequencer and they actually have a several things here that are moving this sm floating island one i don't even know where that is but apparently it's moving somewhere in our level oh we can actually click it and it shows up in the level but actually it's i don't know it's not here apparently let me do a simulate so i'm simulating and you can see that these three things are red meaning that they're actually not working in the sequence here only this one's working it's white which means it's in the level so these three things here they were added at some point and then removed so what we can do is we can just stop playing here and i'm actually going to delete these three tracks we're going to make our own so just right click delete we'll just keep this one here and then now we have this here called s moving platforms but there's no sequence in here either so i'm actually going to delete this as well and now what we can do is make our own sequence so i'm gonna browse here let's right click let's go to animation and then level sequence s underscore moving islands i guess i'm going to take this and drag it into the world just going to put it here because this is where it's going to be close to i'm going to double click it now and so now it's empty and so we want to make some islands that move like back and forth that the player has to jump on to get across so i'm just going to grab let's see it's just going to grab this island and just duplicate it and then let's make it smaller let's do like i guess three and i'm going to reset the scaling actually there we go okay so here's an island starts off here wait now let's get it close to the platforms get lined up correctly there we go like this height is good let's just make it go like left to right you know so it's kind of hard for the player to get on to so i'm gonna set the location here it'll start here and then in our level sequence here hit track add actor to sequence and then up at the top add floating island s57 boom okay so this is the location we want i'm gonna open up transform we just care about location i guess if you wanted to rotate it while moving we could also update the rotation but anyway right here at zero 0 i'm going to hit this plus sign that adds the current location and you know what i will add the rotation because that's kind of cool and so let's say after you know 30 frames or so that's 30 frames per second so after one second let's put it in front of the player here and let's rotate it i'm going to add location rotation well the rotation got changed i don't know why rotate it again there we go i think it i think it worked that time yeah you can see it moving and then at 60 maybe put it over here let's add the location i'm going to rotate it again add rotation okay so now with the sequencer selected let's go to autoplay and loop indefinitely yay oh we didn't finish the end okay so now we want to come back up to 90 and i'm going to take this keyframe here i'm going to copy it and then at 90 i'm going to paste from transform location and then for the rotation i'm actually going to rotate it myself and then at 120 back to the original so just gonna right click copy and then at 120 paste location let me see so we rotate rotate my dog's barking and then here i'm going to rotate it a little more okay cool so let's simulate goes over looks kind of silly whatever you can you kind of get the idea here okay so that's moving there now we want to do another one we want to do like multiple platforms to get the player across so i'm going to duplicate holding down alt i'm going to scale this one up let's actually make this one stationary so the player has to get on here then he gets here it's stationary i'll do another stationary because i don't want to spend too much on the sequencer and this thing's kind of higher so i'm going to rotate it a little bit just to get it up to the same level maybe go right here and then now let's do one more sequencer floating a moving platform right here so i'll have it start here and this one got duplicated in here i'm going to delete this let's add this guy so go add a sequencer floating on island 60 add the location rotation i'll just say actually i'll ignore the rotation and if you want to delete the keyframe just select it and press the delete key so at 30 seconds let's put this like right here make sure the player can actually get on it like that add keyframe and that's 60 let's put it over here at 90 put it back here and then whoops i don't know why i added the scale rotation but then at the end we want to copy the original location and then paste it okay let's see wow look at that okay moving platforms cool and now we need to place another checkpoint here so i'm just going to come up to the checkpoint i'm going to hit this browse it takes me right to it and i can just drop it in bump up the scale on it as well now if you notice with the platform it gets to the end here and then it kind of pauses and that's because in the sequencer this red bar is actually the end so it's ending at 150 with nothing going on so if i drag this here to 120 that's now the end point and then when i simulate you're going to see it's going to hit the end and then just go right back just like that and same with this guy so that guy kind of jitters there and the reason for that is the rotation is off you see the rotation looks like that here so it looks different so i want to actually take this and copy the rotation this one i'll delete it and then i will paste the transform rotation so now here it's the same as here so now it's going so now when i simulate you can see the rotation stays the same and it's really a moving plow okay whatever that might actually end up being really difficult for the player but let's go ahead and play so i'm just gonna cross the first moving platform and then now i gotta get on my spinning island of death here let me on okay i suck i'm gonna cheat and move my player start right here okay let's try to get on my own platform oh my gosh i made it okay maybe rotating is a bad idea okay how am i gonna do this go okay no so easy solution i'm just gonna delete all the rotating screw that so now it doesn't rotate and our life will be easy boom boom okay come here come on there we go oh we made it checkpoint yay okay so that's it for lesson two or activity two let's let's move our players start over here now so lesson number three reach new heights with power ups and collectibles working with public variables in unreal engine and basically we want the player to be able to jump to this island here because currently the player cannot so in our blueprints folder here they have this jump boost let's open it up take a look at it but like before we have a mesh a collision sphere and text so all of these things can be added from up here so static mesh you have right here if i type in sphere you have this sphere collision so these are just things that they added to the blueprint and you can add them as well and like before we are once again using the begin overlap so basically i'm first going to take it and drag it into the level let's put like right here and let's just simulate and see what it looks like okay so you can see that spins around that's cool it's actually rotating and what that is is this rotating movement this is a component as well so i can actually just delete this and then it won't rotate anymore so let's say you're making your own blueprint and you want it to rotate you just go to add component start typing rotate and then you get rotating movement and then this value on the z that's what's making it rotate so if i simulate so now if i simulate it's going to start rotating again but this z value it's rotating along the z axis this blue arrow that's z so it's rotating around that now if i put 180 on like the x-axis here and then compile it's going to have a just a way different rotation see so we'll set this back to zero and then 180 is also the rate right it's the speed so if i set this to like 720 now it's going to rotate really quickly as you can see and this is really getting annoying this warning that keeps popping up for me it's going access none trying to read property get player character in the third person game mode at the node assign on destroy so you're going to be getting warnings a lot when you're coding and beginners have a tough time reading these warnings they don't understand what they mean and so let's kind of walk through this morning here so access none whenever you see this in your errors it means that whatever is being referenced is not being read it's like saying it's invalid it doesn't exist etc and then you can kind of read through here this call func you want to ignore that but the part after a get player character this is the important part and then it tells you which blueprint this error is happening in and this is in our third person game mode which we can click and it takes us to it and then even further you kind of want to ignore this but then the node a sign on destroyed we can click this and that's this event here so basically what this error is saying is that this get player character this value is not valid doesn't exist and i think it's because this whole event when we play the game like let's play it's not going to give me an error this time watch no error but when we simulate it does give me an error and the reason why is because when we simulate there's no player character in the game it's not spawning a player so this event is getting ran and even though we're simulating we're only simulating but this game mode still gets called this begin play is still getting called even though we're just simulating and saying that this player character doesn't exist which is true we're just simulating we're not actually playing so there is no character in the level so in other words this error isn't doesn't really matter it's not a big deal we don't really care about it because it's just when we actually play it works so who cares however because it's annoying me i'm going to show you how to fix this so what we want to do is off of this pin i'm going to drag off i'm going to type in valid let me get this is valid node i'm going to select it and i'm also going to take this and plug it in here and now i'm going to take this and plug it in here so now what we're essentially saying here this is a very handy dandy node here this is valid we're basically saying that only run this event this function or anything else after it if this player character is valid if it does exist if it doesn't exist do nothing but we could also do other stuff off this right if you wanted to so now when i simulate it's going to get the code is going to get to here it's going to say oh the player character doesn't exist let's just do nothing and no more errors okay so that's just a good little lesson on debugging there and fixing just simple warnings you know off of this you could also do something else like a print string and we could say player character does not exist i can make this text red i can make it last for five seconds and now when i simulate in the corner you can see player character does not exist it's going to stay there for five seconds there it goes so print strings are really handy and learning how to debug is going to be probably your most important skill ever but yeah so i'll just leave this here that fixes that warning that we were getting or that error so now back to the jump boost here 720 is really quick i'm going to put it back to 180 it's default now let's go to the event graph here and i'll tell you what's going on so this other actor it's just looking for an actor so whenever anything overlaps this jump boost this gets called and if you do a print string here kind of showing you debugging stuff again if you take this other actor and plug it in what's going to happen is when the player overlaps with the object here specifically this red collision sphere it will print out the name of that actor in our case it's going to print out the character so if i play and then i walk over this thing you can see it says epic character in the corner and that's the name of our character epic character so i can delete that now and just reconnect this because we know it's working we want to get information from the player character the epic character because we want to make the character jump higher so by default this is the player's jump once i hit this we can now jump much higher as you can see and so the way we're changing that jump velocity as you can see here that it's set to 1500 the way they did this is they just made a variable down here and called it jump velocity but realistically you wouldn't even need to do that however the reason why they did do this is because let's say you didn't use a variable here you just wanted to manually set this to 1500 then 1500 would be the value for every single boost you put in your level but let's say you want this boost to be like 1500 then you make another one this one you want to be 3 000. that's why you make this variable here so they made a variable of type float you can just come down here create a variable right so by default it's red which means boolean but i can just click this change it to float and now it's green and i can drag it and do get and then now it'll work right i'm going to show you a shortcut before i do that let's go backwards a little bit so we're casting to the character this is our epic character right here the player character and it's like okay where do i adjust the jump where is it so in the character you have to click this character movement on the left and then you have all these variables that you can play with like the walk speed this is the speed of the player you have the gravity scale lots of different things here but here's the jump right here 600 is the default jump velocity or actually it's 420 they set it to 600 so i'll keep it there and then we have air control i guess they adjusted that as well but yeah you have all these different things you can play with to adjust the character movement and so what's going on here in this blueprint is that we're casting to our character now again what casting means is you're trying to get information from a another class so in our case what we're doing is we're trying to get information from our player character from the epic character that the player is playing this guy right here we want to get his access to his jump information which is here in the character movement we want to be able to edit this value so when it comes to an overlap here it just says other actor and all it's talking about is an actor object reference and remember anything in your level is an actor so this is an actor that's an actor this blueprint is an actor your player in the level is an actor everything is an actor so that's why it's asking for an actor reference here it's just an actor object and what that means is that everything derives from actor for the most part so if i come up to the content browser and i go to uh you know create blueprint here you can see at the top it starts with an actor then it goes down to a pawn and you can just read these things here it says a pawn is an actor and then below that is character which is what the player is right the epic character so it's a hierarchy it goes actor to pawn to character or rather it goes the other way around it goes a character is a type of pawn which is a type of actor okay so it's like this hierarchy and so because this epic character is an actor we're able to drag off of this other actor we can type cast and because everything is an actor like i was saying look how many different classes we can cast to it's just so many so many different classes that we can cast to here in our case we want to cast to the epic character because that's what the player is playing so you drag off this and you do cast to epic and then epic character will show up now like i said because everything is an actor we could technically cast to all of these different blueprints here what if we wanted to cast to the checkpoint we could drag off this and do cast to bp underscore and then there you go there's checkpoint there and then there's coin so there's all sorts of things you can cast to basically everything and because everything is derived from an actor that's why this is such a powerful node right here so we're basically saying we know that the player overlapped the jump boost here so now let's access information to the character that overlapped it so now let's get information from the character and let's change it but you can't just go other actor and then you know set jump z velocity doesn't work that way because we have to go you know deeper we have to get more specific so we we have to first cast to our you know epic character or whatever name character that you have okay so that's just a little primer on casting and actors and things like that so as a beginner it might be kind of confusing but you'll get comfortable with it as you you know continue to develop and personally i don't do casting i don't like to use casting i like to use interfaces but we're not going to touch on those in this tutorial but if you take any of my courses i'll show you why we use interfaces instead of casting and why i think they're just more powerful and better on performance and then off of this pin here we can either we can get all of these different variables down here as well as components up here so for example let's say i want to get the sprint speed watch this i can do get sprint speed i'm going to move this over so now we got the this sprint speed variable the sprint speed is set to 1200 so let's say we want to set the player's movement speed to now be 1200 right so remember by default in here character movement the speed is 600 by default but let's say i hit this jump boost but i also want to increase the character speed off of this character movement i can search for walk speed so let's just drag off here and search walk speed i can do set max walk speed so now i can set it to a new value i'm just going to plug this in like that let's say i want the speed to either be if i plug that in it's going to be set to whatever the sprint speed value is which is 1200 so i can either do that this will double the character's speed so now when i play and i hit this i'm now twice as fast but anything you put here will make it fast right so let's say i want to make the character super fast put in 5000 there and now i'm like extra fast jump all the way over okay goodbye but yeah you get the idea so i can adjust the movement speed of the player here i don't want to do that though i'm just kind of showing you an example you can hook this back up so what we want to do is we want to cast to our player character and then we can grab the character movement from the player and start adjusting things with it and in our case here in this example we're updating the player's jump to be 1500 all right and then let's continue so toggle visibility sm powerup so basically what this means is the player overlaps with the object and then we're taking the mesh here so this mesh i can actually just drag here and then there's all sorts of different things you can do off of it but to give you a more general idea if you click the mesh up here these are the things that you'd be editing so this toggle visibility my guess is it's just turning it off right toggle visibility turn it off make it invisible it's currently visible we hit it it's now invisible that's what this is doing there is another way of doing this like i said if you click the mesh here you have this visible then you also have hidden in game so by default it's visible and it's not hidden but let's say we want to make it hidden i would just drag off i'm going to type in hidden and we get this set hidden in game wow this is cool right so we're just literally getting these functions and values off of the details over here so i'm going to uncheck this i'm just going to move it up and then i'm going to plug in this one and let's set new hit into true so now when the player overlaps with this object down here we're setting this hidden in game to now be true which is going to hide the mesh so when i play and i hit it it's now hidden so that's what this does so we make it hidden and then the collision this is sphere collision so that's this here so by default we have the collision set to overlap all dynamic once the player collides with this object and we boost the player's jump velocity actually what this is is the query results so that would be this here so if i set this to custom it's just updating this right here this collision enabled you can see it says set collision enabled and then right here collision enabled you have these four choices see so that's how you edit collision in the game during runtime so that's what this is doing here and then again we're playing sound at location oh look they use sound at location this time so there it is and then we're delaying so what's the cool down time here four seconds so after four seconds this power up gets turned back on so they toggle the visibility which means it turns back on and then they set the collision to be enabled again so after four seconds the player can hit this power up one more time and then look in his valid node and all it's doing here is checking if the player is valid if it exists if it exists then set the player's speed back to 600 after four seconds see so we delay for four seconds and the players jump goes back to the default of 600. so before i test this remember i replaced this visibility with this hidden in game so i'm just going to delete this because we don't need it we'll just go back to what they had but i personally like to use this hidden game i think it's nice to use you can make the whole actor hidden in game if i just disconnect this it will hide this whole entire actor everything here will be hidden that's why i like to use it i'd rather just hide everything so as an example let's actually do that i'm going to move this out let's set the whole entire actor to be hidden in game and then i'm going to press ctrl w i'm going to disconnect these and then after four seconds i'm going to unhide the whole entire actor it says target must have a connection so it's kind of lame but basically it says self here but what we need to do is right click type in get self get a reference to self now we can well we can't plug that in so i'm just going to drag off to set actor hidden in game okay i'm going to delete that we're going to use this one here i'm going to take this i'm going to control copy delete paste and then now we'll set this one to true okay so now when i play i hit this disappears for four seconds and then after four seconds it's going to come back i'm not going to jump high anymore hit it again yay so now you know a different way of hiding actors but this is i actually prefer doing it this way and hopefully you're kind of learning some blueprinting here now back here again i wanted to show you a shortcut to create variables so instead of having to come down here and add variables every single time let's say we didn't have this jump velocity variable pretend it doesn't exist so we get our character movement here and then we want to adjust the jump z velocity and like i said if you come into the character here click character movement these are all different things that we're adjusting so this max walk speed you can adjust all the stuff here this mat this min analog walk speed i could type that and it would pop up this mass here so if i drag off this and do like set mass you see it's right here i'm literally just setting these values here i'm just calling them in blueprint so you can get access to all of these different values here using this character movement right here but anyway so let's say we want to adjust the jump z velocity you can right click this and do promote to variable and you could say something like new jump right here so that's our new variable i'm going to compile it but if you click the actor here you can see here in the details panel it doesn't have our new variable but it has the old ones has a jump velocity of 1 500 and the cooldown time of 4.0 four seconds the reason for that is because when you make a variable if you want the variable to be editable in the world you have to do what's called instance editable so you check this and then you compile it and now you can edit it in the world so now out here we have new jump of xero in a default category and that's because if i click new jump the category is default and has a value of 0. so this i is the same thing as clicking that instance editable so let's say we want to use this variable let's say jump velocity and delete it like doesn't exist anymore it's now gone if i click this you can see it doesn't exist anymore so let's put this new jump let's go category jump a default value of what 1000 let's just say that compile now out here you can see new jump 1000 so let's say that one's a thousand i'm going to make another one here now this one i could set to like 2000 maybe a cool down time of eight or six i guess six is our max so if i click cool down time the slider range is from zero to six with a value range of zero to six that's why i cannot set it more than six so with new jump we could say a value of one thousand to two thousand one thousand to two thousand so now two thousand is now the max so if i try to set this to five thousand we'll go back to two thousand so now when i play i'm gonna hit this second one i now have a jump of two thousand i can jump super high oh no but anyway i'm going to delete this guy out of the world and we'll just keep this guy we'll put him back to 1500 and then the next thing we're going to do is we're just going to add some of these coin pickups in the level so first one we're just going to put i guess we'll put like a couple on each island here hold down alt and the end location is up here activity 3 destination so let's just keep adding some coins for the player to collect right here right there maybe some more up here and then for the player to jump up here we need another jump boost so we can either select this guy and copy him over or in our case i'll just drag this one in like that and he might need more than 1000 here so let's try 2 000 and so i'm going to put one more coin up here and then we need another checkpoint here so i'm just going to go browse to a checkpoint and drop it on the platform and then let's scale it up a bit or not let's get it like to fit in between the wood all right let's play our activity number three let's get the jump boost get our coins another jump boost here oh no okay well i landed on the checkpoint that's cool so we beat activity three we're so good okay let's move our player start actually i'll just delete it i'll add another player start right here so we've beaten activity three it's time to move on to activity number four but before we move on to activity four let's just quickly look at the coin blueprint you can open it up here so it wants us to wait until activity five but i'll just tell you all that's happening really quickly so again the overlap right like i said you're going to be using these overlaps all the time when you make games so the player overlaps with the sphere here in the coin and we're casting to the third person game mode that's up here and then it's getting the current coin count so you can tell with it dragging off here it says coin count and it's green up here it says it's an integer this means that there is a variable in the third person game mode here called coin count and it's going to store the players collected coins so we come here let's just look for it there it is it's in player inventory it's called coin count default is zero starts at zero so every time the player hits one of these coins in the world right here we're taking the current coin count in the game mode and we're just dragging off do a plus sign integer plus integer we're just adding one and then if you drag off of this and type in set coin count we're taking the current coin count which in the beginning is zero we're adding one to it and then we're setting that to the new amount so we're updating the coin count variable in the game mode to that new value whatever it is here plus one so the character hits the first coin we take zero plus one we now set it to one when the player encounters another coin this coin count is now going to be one we're gonna add one to it now it's gonna be two so we have like one two three we have a lot of coins right a shortcut here is i can come to the world outliner i can select a coin here look at this if i hold down shift and click to the bottom it says nine selected so that means we have nine total coins in our world so if the player collects all the coins this coin count value in the game mode will be nine i'm actually going to move that over i'm gonna make this stuff be activity five because this is like the hud and stuff like that which we don't have yet and actually at this point we're doing everything else we are playing the sound we are destroying the actors so this destroy actor this is another common node you'll use this just gets rid of the actor deletes it from the world so specifically what's happening in our case here is the player overlaps with the coin we add one to the coin count in the game mode we play a sound and then we destroy the actor we remove the coin from the world forever so this is going to be activity 5. i'm just going to move this out of the way i'll put that in there because we're doing all this right now we do all this in activity three but now it's time for activity number four activity four the key to unlocking the final area working with conditional statements in unreal engine so basically what's happening here i'm going to show you the player then proceeds back down here and the player jumps up here to this building it comes to this lock door he presses e and says key needed and the door won't open so we're supposed to add a key somewhere in the level maybe you want to add a bunch of more power ups and jumps and things like that maybe you want to put the key way over here i don't know it's up to you where you want to put it so there's gonna be two blueprints you need the key blueprint and then we have this locked door blueprint so i can right click and browse to it we have this door locked so we can open this up and we got a lot of code here as you can see so let's just go through it one by one just to kind of help you understand what's going on here so in the viewport here the event graph says begin overlap with the box collision so up here is the box collision and that's this so when the player overlaps with this box here you can see in the world it's right here when the player overlaps with that box this is just a quick check to see if the door is open so so this is a boolean this is either these are either true or false so by default we want door open to be false and that's all we're doing here so to do this this is called a branch node it's just checking true or false it's a condition right and you're going to use these all the time in your programming for all sorts of things like a good example is if the player is attacking with a sword you would set you know currently attacking to true and then what you want to do is you want to set a branch node and you want to say like let's say the player goes to click the left mouse button to attack you want to check that the player is not currently attacking because if if you don't do that check every time the player presses the left click button it's going to attack which you don't want right like let's say the player is like mid animation and the player presses left click again to attack it also cancels the current attack and then starts over you don't want that to happen right you want to be smooth so you only want the player to be able to attack when the player is currently not attacking so that's really what these do so so we're just checking here that we don't continue unless the door is not open meaning door open is false then we can continue so now what we're checking here is if the player has collected the key but we're casting to the third person game mode here that means in the game mode there's a variable called have a key so let's find it so right here have a key by default it's false obviously and now we do another check so you can just hold down the b key and click you can just make these branch nodes easily we just want to check if the player has that key so we're gonna have to make a blueprint that updates the game mode and says the player does have a a key yes he does right so we'll do that after this i just want to go through this so if the player does have a key if it's true we do what's called enable input for this actor this is this is actually confusing so this get player controller we haven't even talked about the player controller yet i don't even think we have one like a custom one at least we just have a default one so we have a character we have a camera shake and we have a game mode we don't have a player controller now if we wanted to we could right click and create a blueprint class and we could create our own custom player controller but we don't need to do that for this project by default player controllers have this enable input action here so what's happening here is if we type in get player controller get this and all we want to do is enable this actor this door to be allowed input meaning the player presses like the f key or the e key and if so this actor can now accept that e key and open so like i said it's kind of confusing but that's exactly what's going on down with this code now so we'll get there in a second but here's the false statement now so when the player comes up to the door doesn't have a key it's false this locked door it's going to pop up and say what's it going to say it's going to say key needed i guess let's go see so it says press e to open the player gets close it says key needed on the bomb do you see that the bottom of the screen there says key needed that's all that's happening here it fires automatically because every time the player overlaps this event gets fired this is going to be false because we don't have a key so it's just going to keep saying that key needed every single time it's just drawing text to the screen and this is how they do that they do that with widgets so i don't want to get too much into widgets but we can browse here we can open it and we can look at it so all this is is the umg editor this is where you make like you know health stats stuff like that on the screen information but all this one is doing is just saying key needed it's just drawing this text on the screen when the player overlaps with it now and overlap this one we haven't seen yet this basically means that if the player is currently in the box let me go back here so the player is in this box here the collision once the player leaves the box it's no longer overlapping that's called end overlap right here and then this event gets fired so these are going to use a lot as well you can like run functionality whenever a player leaves a collision volume like maybe you want a door to close or something when the player leaves or maybe play a sound in this case all they're doing is disabling input on the door and then removing the widget right so we create this text widget on the screen we actually promote it to a variable here and that's so we can reference it later down here so this is the same variable and then this means we're removing it from the screen so you can drag off this just type in remove remove from parent that means remove the widget from the screen so that will remove the text off the screen and then they drag off they go set they're setting it to nothing right that's nothing here so that means the variable is now invalid it's set to nothing this isn't really the best way to do it in my opinion i would do it a different way but it is what it is but now let's go down here so this stuff here only works when input is enabled and that's because down here we have input action interact so when the player presses the interact key it's going to run all of this stuff here so your question might be what is the interact key well let's go find out so if you come up to the world here you go to edit project settings on the left there is input right here these are your input actions so we can expand all of these and we have interact right here that is this interact you can use this anywhere we can also use this in the character here we could type in come down here and type in interact and it will pop up there you go so now here let's expand this and this says it's it's set to the e key with the keyboard oh there's this celebrate what's that middle mouse button not really sure what that does but you can see it in the player here if you press the k key it will kill the player if we hook that up it's unhooked right now but we could hook that up and kill the player and then right here quick game this is actually important to do when you package the game because if you don't do this there's no way to close it unless you alt f4 so the escape key quick game i'll keep that but anyway down here the player presses the interact key which in our case is e we cast to the game mode and we just want to see if the player currently has a key if the player does if it's true do once meaning only do everything after this one time never do it again and then what we're doing next is now with half key we're now going to set have key back to false so the player has collected a key it's been set to true which we haven't done yet we got to go set that up we're going to create our own blueprint for that and then once the player presses e on the door with the key you now set it back to false so it's like it's as if you're removing the key from the inventory this is how you would do that and then we'll play a sound and then we do a timeline to open the door so this is kind of advanced timeline animation but then this is actually incorrect we don't want to set door open every frame so basically the way a timeline works is i'm going to open this up you double click and the length is five seconds so basically what's happening here is the door is gonna rotate for five seconds and every frame it's updating its new location so it's almost like a tick function which means it's just running constantly like if you're getting 60 frames per second then this timeline is running 60 times per second over the course of five seconds so so it goes across this little curve here and it's updating the rotation throughout so you get like a smooth rotation that's all that's going on here you can see we do we you can see we have the door here so this sm door if i click sm door that would be this whatever this meshes here so it's the blue stuff in here it's not this thing here this is just the wall this door is the blue thing in here so all it's doing is taking that blue thing and rotating it for five seconds to a new location whatever that is and so the problem i see and all of this stuff is getting updated as well so this stuff is all running 60 times per second as well so we keep setting this to true over and over and over again that's bad programming so instead what we want to do is disconnect that i'm going to set finished here so when the door is finished opening then we set a door open so this only runs one time now this here i'm not exactly sure what's going on here but it has to do with the hud which we haven't uh worked with yet yeah these nodes make the key icons show up on screen i don't know we'll come back and we'll change it looks like it's set the opacity to his point okay 0.3 means like almost invisible so before it was plugged into here which means right away the opacity of the the like key image which we haven't seen yet was getting set to 0.3 almost invisible this was getting set 60 times per second that's just bad that's bad programming bad on performance you don't want to do that but now if i do it from here after we open the door this the key icon on the player's hud the screen it won't get set to 0.3 until after it opens so instead what i'm going to do this is another cool little function here i'm gonna do a sequence node so that means it goes from top to bottom so first it's gonna whatever you plug into zero it will do first and then one it'll do second so actually what i'm gonna do i'm going to play i'm going to do this first so we're going to set the hud to 0.3 the key icon which we again we haven't seen yet i'm gonna go open this hud reference just so you can visualize it i think it's gonna be this so t key so by default it's invisible but it looks like this so by default it's hidden but this is what it looks like so we're setting that 2.3 right when the player opens the door and then right after we do play from start and we do the door animation so kind of some difficult concepts going on here i can see that but hopefully you're kind of understanding the more you work in blueprint the more all of this will start to make sense but yeah we set the door to open and that's it and if you come up here remember door open is now true so this will never run again because we have nothing off true you could do unless you wanted to do something off here maybe you want to kill the player i don't know but now this brings us to our next assignment which is to actually make this key blueprint we don't have a key blueprint so we can't even open this door without a key and keep in mind all the key really is is just this boolean being true or false so if it's false the player doesn't have a key if it's true the player has a key that's all it is it's not anything in-depth it's nothing crazy that's really all inventory systems are like at a basic level it's just does he have it yes does he not have it no okay so what we want to do is we want to make our own blueprint now so i've taken you through several blueprint actors here let's now go make our own i'm just going to do it up here in the content i'm going to right click blueprint we just want to make an actor because an actor is just like a very basic object so you click that let's just call it bp underscore my key and if you check the other blueprints all the other blueprints you can see in the top right parent class actor parent class actor actor and actor and that's because most blueprints are actors so that's all we did here we clicked actor we open it up you can see it says actor so this is what an empty blueprint looks like and we want to make it a key so what do we need when you think about what we need in this blueprint so at minimum we need a mesh we know that for sure so the player can see it and then number two we need collision so that when the player actually collides with the object we can tell the game mode to now say yes the player has a key so let's come back in here let's add component let's add a mesh we can say that this is the key mesh and then click up here type in just collision and then you get sphere you can also do a box if you want but let's just do a sphere and i'm going to drag this on top of the scene root attach it so so i don't want it attached to the mesh so now let's go find a mesh so the project used this blue key but you can use whatever you want so if i come up to the content folder i go to full filters static mesh these are all the different meshes the project has by default and then you can add any that you want for a key let's say we wanted this powerup a to be the key icon or any of these shards right whatever you want just pick one maybe this flower is the key i'm just going to go with this flower for fun so select your mesh go to your blueprint select the mesh here and then click the arrow gets added as you can see and i'm going to drag this into our world now you see that the mesh is really small again if you wanted to you could go hide the key way out up here if you want i'm not going to do that it'll just take too much time i'm going to go hide the key like let's say i hit it over here right i'll put the key right over here and now that flower is really small so i'm going to scale it up like that and now you can see it's much bigger but then that means i want to make this collision sphere big too so i can take this and you can either scale it or change the radius here so if i hold down left click i can drag oh god i drag too much it's probably better to just type let's go like 70 or 60. there we go so now you can see the sphere and now the next thing to do is click the sphere scroll down and overlap all dynamic is fine but i'm going to set this to overlap only pawn just to be more specific and then generate overlap events this needs to be true if you set this to false it won't run these overlap events so set that to true compile and then now scroll down on component begin overlap let's click the plus it creates an event for us and we can delete this stuff up here so other actor what we're doing if you recall is that when the player overlaps the flower we want to update the key now the developers of this project put the key in the game mode and i can understand why they would do that in my opinion i would actually put it in the player controller i wouldn't actually put it in the character though and that's because these characters they die and respawn and stuff like that so let's say you had a variable here in the character called my key if you updated the key in the character and then you like fell off the cliff and died then if you look in the game mode what happens is the character actually gets deleted and then it gets respawn pretty sure that's what's going on and every time the character gets respawned it's as if it's like a fresh new character so the key would be set back to false and the player won't have a key anymore so that's why they're adding it in the game mode in this case but for me personally i would make my own player controller and do that in the player controller and that's because the player controller continues to exist whether the characters are alive or not so a good example is if a player dies in the multiplayer game you might delete his character and respawn it but the player controller continues to exist and any you know any stats the player has accumulated over its play session the player controller would hold on to so that's just a quick little overview of why player controllers are important but but we'll just keep doing what they did here so we want to come to the game mode and update its key so that means in my key we need to cast to the game mode so if you remember in the lock door this is what it looks like so in order to cast to the game mode you have to use this get game mode function so right here i'm going to right click get game mode and then off of this i can type in cast to and then these are all the game modes in the project so in our case it's called third person game mode now connect that and then i'll remember in the door locked we're checking for the key this is a git have key but we want to use set have key so here in the game mode we can set it to be true so off of this let's now go set i'm just going to type in key and this pops up we now set this to true so the player now has the key and then after we set the key we can now destroy actor right we can destroy this key blueprint from the world we can just delete it so we update the game mode we tell the player that yes he now has the key let's now remove this flower from the game so really that's all it is it was really just a simple blueprint just adding the key like i said inventory can be really simple like that so let's run over here let's pick up the flower it disappears it deletes so the player now has the key it's now true we come up here we now press e and the door slides down we can now go in you can see in the bottom left corner the hud has been drawn at 0.3 so what i want to do is i want that to show up really nicely when the player picks up this flower so in the door locked here remember here we set the opacity to 0.3 so this is how they did it they got the hud reference then they got t key and then sets the color and opacity kind of confusing but basically what's going on is the game mode has a variable called hud that's the reference to the hud that is this and then what happens is inside of the hud there is a t underscore key variable let's go find that so in the hud we have right here t underscore key in the top if you look here we have it checked as is variable okay so that means we can access it and then what they're doing with that variable is they're setting the color and opacity so this function must exist in the hud so let's look for it so we have t key selected where is the color and opacity oh look right here it's called color and opacity so by default it's set to zero meaning it's invisible one would mean it's fully visible as you can see so what we want to do knowing this information we can do this same thing here in our new blueprint before we destroy it right now we can either do what you're actually going to do in the real world which is you'll just copy this and then paste it you would do that and then plug that in but let's say we wanted to do it from scratch we would just go we want to get the hud right so the hud is called hud ref so here i would drag off and do get hud and we get this get hud ref that's the name of the variable and then we want to get this t underscore key so now i need to drag off and type in get t underscore key there it is and then in this variable these are all the different things we can adjust right we could adjust its visibility we could say whether it's enabled or not it's transformed we can adjust all the stuff but we want to do the color and opacity first so in that case i'm just going to drag off i'm going to type in color and opacity and you get set color and opacity plug that in and by default it's one one one zero so let's click this let's go one one one zero this is what it is by default but we wanna make it fully visible right so i'm gonna set the alpha to one like that and then i'm gonna hook it up now let's play okay i come over to the key in the lower left corner you now see it's fully visible 1.0 on the opacity and i can open and then when i open it goes down to 0.3 now let's take this to the next level just to show you but if you come down here to render transform we have this transform let's see if we can set the scale in the key here let's try it so let's drag off this let's go trans form so set render scale this might be it here let's try this plug this in so by default obviously it's gonna be one one right but let's do something like five five just to see what happens all right let's see what happens oh my gosh it's huge that's like not even the full thing that's like half of it and it still stays big even though i open the door because we never set it back it's still set to five five so yeah this is just kind of teaching you how you can access functions and information and stuff like that using these variables in other blueprints and widgets and things like that so you get like a reference to it right here we're getting a reference to the game mode and then off of this we're now getting a reference to the hud which is actually set here in the game mode we make it a variable right there and then we're getting a reference to that t underscore key image variable which is right here and then we're just messing with these values here so pretty cool right so i'll delete that now and then we can also play a sound i forgot about this let's play sound either at location or 2d i'm gonna do at location and then let's do get actor location this is the location of the key blueprint the flower and then let's play a sound so we need to go find a sound so let's go to audio key okay cool let's use that and just plug it in so now it will play that sound and then destroy actor now there's another blueprint it has here called end goal or something like that it wants me to place it up here inside of the building so let's just do that okay end goal so now what happens in this blueprint so what's cool here in the outliner when you add the blueprint to the level you can click and then on the right you can click edit it'll just open it so now it's going to do all this stuff when we hit that end goal so it's going to pause the game it's gonna make a new widget called game completion let's see okay so it's gonna pop this up on the screen okay that's what this add to viewport does whenever you make a widget you have to you have to run this ad to viewport or it won't show then we're removing the hud from the game mode so we're just removing the old one with the key and stuff like that and then this begin play so this runs right away so we can just go simulate this see what it looks like yeah so it moves around like that and that movement is driven by these um these timelines here so it's got one two three four different timelines rotating those crystals around see set relative location and rotation four different shards here so a lot of different timeline animation going on but yeah that's generally what's happening so i get the key and i suck at life okay let's not fall off this time so i go through the door and then i hit this shard and then that screen is going to pop up right there so pauses the game says the amount of coins i have the time it took gems which we didn't really do now once you have your game completed you're going to want to go take your player start here and then you know move it back to the beginning here so you could play from start to finish but then it has one more lesson there's a lesson five so let's go see what that's about so lesson five is more about just doing hud stuff and it wants us to add the coin and gem counter the key icon and the jump boost icon to the player hud the ui it also wants us to package but i won't go over that so what we can do is in the hud here remember we have these all these elements here which are invisible let's set the key by default we want the opacity to be 0.3 because that's what it was getting set to when we didn't have a key so but by default let's make it point three here the jump boost let's also make this one point three and the coins counter color and appearance let's make this a one and then gems we haven't done anything with gems it's you know it's gonna be very similar to coins i'll let you do that on your own but let's just do the jump boost let's make the jump boost be an opacity of 1.0 when the player collects this jump boost so let's come into the jump boost here we cast to the character we update it's jump and all that now before the delay we want to also set this alpha value to one so here in bp jump boost we also want to cast to the game mode so let's go and get a game mode and then cast to third person game mode and then we want to get the hud remember the hud variable get the hud reference and then what's the name of the variable it's called t underscore jump boost so i'm gonna go t underscore jump boost we want to get it and then we want to set the color and opacity so drag off and type in color and opacity we want to set it now i can hook these up you want to set it to one one one one okay and now at the end after four seconds we want to set it back to 0.3 because it wears off so after the delay you want to turn it off so to do that just a duplicate plug in and then drag all the way to the end and now put it back to 0.3 and now let's put a jump boost actually i got one down here so just going to play here i'm going to drop down you see in the lower left it's like a 0.3 but when i hit it now it's 1.0 it's fully visible and now it's worn off and it's back to being 0.3 now when i collect a coin the widget doesn't update the value is still zero you can see the coins i'm getting coins but it's not being updated visually so the game mode knows we have like nine coins or however many we've collected but the hud has no idea so now how do we update this value it says coins colon zero so if you go up here on the right top right you can click graph now we actually have these functions that they've created for us this one's called update coins and what happens when we run this event it's going to get the coin count from the game mode and it's going to append coins colon whatever this number is the count is and then set the text here there are other ways of doing this but this is how they do it so we'll we'll just do that and now you might be wondering like where did this update coins event come from like how did they make it we haven't really seen any events like this the only other one we've seen really is in the game mode here there's this respawn and this on destroyed the only other events we've seen have been the begin overlap and the end overlap we haven't really seen any other events so what are these what what where are these coming from so these are called custom events you can make your own events you can make your own functions up here right you can click this plus function and make your own functions so in your development you're going to use a lot of custom events and functions but let's say we wanted to make our own event you can right click start typing custom and you'll get this add custom event so you click that and then you could say you know add coins to ui this is usually how i word my custom events update coins isn't specific enough for me so i usually make it more specific like this so i'm actually going to delete that event and we'll now use this new one i did and this is now a custom event that we can call from any class that's referencing this hud so if i go to the third person game mode for example here like here here's just a reference to the hud i could drag this off now and type in add coins and now i can you know call this function now here so if i double click this it just goes straight to the function and it will run this event so that's the beauty about making your own events and functions and there's a lot more to talk about when it comes to custom events especially when it comes to multiplayer games because you can set them to run on server or run on the owning client only i don't want to get into depth about that at all in this video but if you do want to learn about multiplayer all of my courses are designed for multiplayer i actually only work in multiplayer i don't really make single player games i just i think you should always just build your games to be multiplayer compatible because at the end of the day when it comes to unreal engine all all your games are running on the server even if it's a single player game you're technically the server the player is the host the single player is the listen server as they call it right here and that's just how unreal engine is designed because it comes from a fps background that's like you know unreal engines always been designed for fps games from the beginning and it's just it's kind of more evolved towards being an all-around engine for all sorts of different types of games but it originally started as a you know an engine for like unreal tournament and multiplayer games and things like that so it's built for multiplayer from the ground up so i like to design all my functionality and stuff in unreal engine with multiplayer in mind so maybe another day i'll do a beginner's tutorial on multiplayer but for now that'll come another day but yeah that's your little mini introduction to custom events here so now how do we add these coins to the ui right so the player runs over these coins these coins are getting added to the game mode like i said it's being added under the hood but visually in the hud this this amount isn't getting updated so we want to update this amount here and if you look here this is called coins counter and up here we have this is variable checked it's true now by default if you do add a text to your widget so i just added a new text it's up here by default your text blocks aren't going to be variables if you want to change the numbers of them and change the text things like that you have to make them variables so that's what's happened here they've made this coins text a variable and then that gives you access to it here on the left and you can now do stuff with it and so in this case what we're doing is after we get the number of coins that the player has we're then appending coins and then after it whatever the number is whatever the amount is and then that's what we're doing here with this set text so the set text this is a function and it updates the text of whatever this value is here so if you look on the right it says text right here it's just updating this so if i actually disconnected that and type in like unity is cringe or something when i call this function this text will now say unity is cringe which it is so i'm just going to plug this back in but unity is cringe but now we want to actually call this event when we pick up a coin so here we have the third person game mode this is in the coin we update the coin amount let's now update the visuals so let's get this hud reference here it's going to drag off to get reference and then now in the hud we can call this event let's add coins to ui so drag off add coins to ui there it is and then we just hook it up and so now every time we pick up a coin it's going to run this event and it will update okay so i'm just gonna click the coin it says plus one you can see it updating wow we're such good gamers okay guys so that is going to do it for the video this is the second long beginners tutorial that i've done and i wanted to make a new one using this project and with the latest version 4.26 so if you're new to unreal engine and you went all the way to this point you know congratulate yourself you've actually learned a lot in such a short amount of time i've also got three courses that will take your skills to the next level you can check the link out in the description but for now i would suggest expanding this game you know add more coins add more islands add more checkpoints build on it make it larger maybe add your own character eventually just things like that there's lots of things you can build off of this and really make a legit fun game okay so thanks for watching guys go ahead and subscribe if you're new here and i will catch you next time
Info
Channel: DevAddict
Views: 427,271
Rating: 4.9524693 out of 5
Keywords: Unreal Engine 4.26 Beginner Tutorial, make a platformer in unreal engine 4
Id: rAVPEGnyatk
Channel Id: undefined
Length: 112min 39sec (6759 seconds)
Published: Sat Dec 12 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.