Do you want to create games in Unreal
Engine but don't know exactly how to start? Here we will create a 3d platformer game
while learning how to use blueprints to create the mechanics. Also, we will reach a
gameplay flow for our game in a matter of minutes so we can test the game very frequently and
build on top of it. There are no requirements for this tutorial, but knowing your way
around the viewport will make development faster. When you finish these tutorials, you
should be more comfortable with blueprints, and also have a good idea on what it takes
to develop a game. And before I forget, if you want to support us in any way, be sure to
check out our store. We have a lot of cool stuff like a free blueprints course, another to model a
castle inside unreal, and our marketplace assets that were made with care and effort. If you want
to learn more, you can consider becoming a member of our channel, where you will get exclusive
tutorials that can take your game development skills to the next level. Let's start by creating
the project, be sure to choose unreal engine 5 and in the project browser, we will create a
blank project. We will be starting this project from zero, so i don't need to update the tutorial.
It happened to me before, that I used a template, and that template changed so I want to avoid that. So let's just create a blank project,
blueprints is fine, and let's call it my 3d platformer and create. Now that the project loaded, let's, let me
put dismiss, update the file. If I press play, I shouldn't have anything here, only this
example map, and now what I'm gonna do is import the needed assets that we will use
in this tutorial. These assets are free and you can find it in the marketplace. Here
in the unreal marketplace, if you search for hour of code you, will find this project. It will
say that it's for 4.26 doesn't matter, just create it, and we will use this content. Whenever you
create the project you need to find where usually you store your projects. In my case this folder
is called unreal projects and it's in documents and it should be under unreal engine hour
of code. What we need to do here is just, open the content folder search for hour of code
and teachers marketplace. We will copy this, copy and we will paste it in our project. Here content right click it, show
in explorer, and paste it here. This will probably break some stuff
needed, but I only wanted the assets. Here I'll press import just in case, and
you will see that this has some blueprints inside it and some maps but we won't really
be using them, we just need the assets. Architecture, there's some roofs, and we
will see how we're gonna use all these assets but for now that's what I needed
to get before starting development. Now we will create the character
this is a key element in any game. So let's first create a folder for our project and here should be three i'm just creating
a folder with the same name of my project so I know where I'm putting all of my assets. Here
because the character is a core feature of our project without it, we won't have any game.
So I'm gonna create a core folder and then here I'll create a folder that will be used
for anything that the player needs to have. Now to create a character, we
just need a blueprint class and here, in the common section we will
select character. This is a blueprint class that will be useful for any type of biped
character. I'm going to call it main character. This class already comes
with some capsule component, a narrow component to know where
we are facing, and then a mesh, a skeletal mesh. Yeah. This will be the
representation of our character inside the game. And, it also has this character movement, where we
can tweak how our character will move, and before I mention that this is used for biped characters
because they already have, for example, swimming, walking, falling, flying, etc... but
it's especially for bipeds because we have a capsule component that if we have
for example, a horse here, it won't fit. So if i needed to make a playable horse it
will probably be a pawn, not a character. So just take that in consideration. For this
example, this character blueprint is just fine. We need a visual representation of the character
and we just need to go to the mesh component, let's change this skeletal mesh, here in the
details panel, and select the epic character rig. This is the asset that we imported from
the other files and, if you open any of these files, there will probably be errors
so just ignore them or just don't open them. Now we just need to bring it down a little bit and rotate it to be looking forwards.
In Unreal when whenever I say forward or when whenever someone else
says forward it means X positive and well Z, is how high or low something is the
vertical value so it changes from engine to engine. Just keep in mind here in real Z is the
vertical value and X positive is forward. Let's adjust this capsule component a little bit,
so it matches better my character, so the radius and also the half height,
maybe a hundred should be fine, and the radius 40. Now if i press play here, we will see that nothing changes. We need to tell
our game that we want to use this character. So let's create what it's called a game mode, right click here let's create a
new folder called framework, and the game mode is part of the Unreal gameplay
framework. Let's just create a blueprint class here we will have the game mode. These common
classes are all part of the gameplay framework and the game mode, specifically, is in charge
of defining the default values of our games and also the rules of the games, especially rules
that have to do with the state of the game like losing, winning, starting etc. and I'm also going
to call it GM from game mode and My 3d platformer. Now let's open it and we will go to the details
panel or the class defaults, if you don't have it, just press on class default, and you will
have these settings. Here I need to assign the default pawn class. This is the character
that will be used by default, so here I'm gonna select my main character. Let's compile,
if we still press play it's it will still be not using the character, so let's
go to the project settings, Edit -> project settings or here in settings ->
project settings. We will go to maps and modes and we will define the default gamemode. Let's
use my GM_My3Dplatformer. So with this in place, in any map that doesn't have a game mode, it
will use my character and right now I have this kind of first person character but we
can see that it's already in the game. Now that we have this character when we press
play, we need to talk about a little bit the three elements for any type of gameplay. This is the
character, the camera, and the controls. The character is how the player will
represent itself in the game, in this case this is my character and
this is how i see i'll see myself. Now I need some perspective like the camera if
i want to do a platformer like we're gonna do, a third person camera will be fine, a strategy
game would probably use a top-down camera, action game probably a first-person camera like this
one. So you need to define the camera somewhere. And then we will define the controls that are the
third key element. So let's start by the camera. Let's open my blueprint character, we
don't really need the game mode anymore, for now, and here in the main character i need
to define a camera. We can add a camera here and this will make a floating camera. Because i know that later i will want
to check the conditions so if i have a wall here i don't want the
camera to clip inside it. It will be better if i create a component
called spring arm, and it will serve as an arm to put the camera in. So here i created under
the camera, i really don't want it to be this way so i just delete it select the root
component capsule component and create it again. So now i have this spring arm
i'll put the camera inside it, and this is just attaching the components. Now you will see my camera is here and it's
good to reset any transformation i did to this camera so i'll reset it here, location. And it
should be every value in zero this will allow us to see how this spring arm is working, and if
we want to change the target arm length it will affect our camera. So, if i press play now, i
will see the perspective of the camera, and also I can change this and it will be affected in
our gameplay, for now maybe 600 should be fine. So now with the character and the camera we need
to define the controls, so we can move around our character. To define the inputs of
how we're gonna control this character, we will go again to the project settings,
here I did project settings also, and we will find the category called inputs.
here in inputs we will have action mappings and axis mappings. Axis mappings are
inputs here it is, that will receive a value between, well, usually between zero,
well, minus zero, minus one excuse me, and one. So if I wanted to, for example, is
used for the movement let's add move forward. And, I could select here the key or if I'm using
a gamepad, the input for the gamepad or also I can press here and press the key I want to use.
So in this case move forward W sends a value of 1. It's not really necessary to create
another one called move backwards, excuse me. Or something like this. It's not necessary
because here it moves forward, I could put another input like I just did by accident. Here
another input press S and this will be a scale -1. Well, the same thing
I'm gonna do for move right. And this will be D, scale one,
and S, A, excuse me, value -1. Now these are axis mappings and they usually
work really well with the gamepad, because if I add for example here, the gamepad usually here is
the thumbstick in y, move forward. This will give me a scalar, so if I'm just moving the joystick
a little bit it will give me 0.2 0.3 etc so we can make the character work. And, here move
right, usually is gamepad left, where is it? X. Now the action mappings are different and are
a little bit more simple. Oh, and I created two, excuse me. It's usually just a key that will be
pressed and released so for a specific actions that have a clear start and an end they
work really well. For example, the jump, jumping, we can add here the space bar or maybe
in terms of gamepad, it's usually the face bottom and button bottom, yeah. This is in, should be a
or b depending on which type of gamepad you have. And with these inputs created, we can go back to
our main character let's go to the event graph, and here in the event graph we will create any
functionality or interaction that our character will have. Let's create a simple jump for example.
So, let's just right click and press the jump, well type jump you will have a lot of jumps
and this has to do with the blueprint we're using that is a character blueprint. But what
we want is the input, input, action event, jump. This will have the name that we assign it so if you change this name you should reflect it
here so jump getting a jump to work is really easy if we're using this kind of character class
because we can just press, call jump, and when we release the character, excuse me, the key
in this case space bar, we will stop jumping. Now if we press play we still can't move but
we can press space bar and our character jumps. With our character jumping, it's time
to add the movement, so let's go back to the main character blueprint and let's save it. Be
sure to periodically save everything. And now we need the move forward event and the move right. We
will create a simple way of making this work move forward and then we will explain in more detail so
here's move forward and also here is move right. Our character already comes
with a way of adding input, and we can use that node by right
clicking and add movement input. We just need to connect it and if I, for example,
move forward, we said that x positive was forward, let's just put one, and if I press play we will
see that with this scale value I will go forward automatically. If I connect the axis value of
this move forward, right now the axis value is zero because i'm not pressing W. If I press W
I'll move forward if I press S I'll move backward. The same thing can be done with the move
right and let's just change it. For example, the scale value should be axis and here
instead of X, X will be zero and Y will be one. Let's press play, and now I do have this kind of
movement. We also need to know that our character should be able to move the camera around and
that thing will cause a little bit of problems with this type of implementation, but we will see
it along the way. Let's add the camera movement. Here axis mapping, I'm just gonna call it turn.
Usually is when you're moving your camera from left to right and here I'm
gonna select Mouse, Mouse X and well because I'm already adding the controller
support we can add gamepad and it will be right thumbstick X. Then we will add another axis
mapping and this will be called look up. Here it's Mouse Y and you
could also add the gamepad right thumbstick. So remember
that maybe the gamepad is not translating exactly with the mouse
movement you can create another input specifically for the gamepad so you can change the
scales or maybe the way you handle the movement. For now this is more than enough
for this example, so let's use this. Let's create the action event called turn, axis event
excuse me, and then the event called look up. Here it is. And here we can add some Yaw.
Add controller yaw input, we are gonna connect it like this, and
this one should be add controller pitch input. If you don't know what yaw, pitch, roll
is, whenever we have a camera and hopefully I can add the camera really fast here, this
camera will be fine. Whenever we have a camera, if our camera is rotating this way it's called
yaw, if our camera is rotating up and down it's called pitch, and if our camera is
rotating on its sides like this it's called roll. So that's why here turning should change
the yaw and look up should change the pitch. If I press play now with my mouse, I can
turn around and right now I can't look up or down. But let's see what happens
with my controls. Now if I press W, we are still going to the same direction. Why is that happening? Because we are
only adding movement in the X value, so we need to change the way we are adding
this movement and that's what gonna do next. Let's fix first the camera rotation because i only
can move my camera in this axis but not in the y-axis and if we see these events, we can see the
mention of the controller. Controller yaw input, controller pitch input. Controllers are a
class that will possess our character so, If I press play, this is just a character and
if I add another character to the map here, let's just add another main character,
you can open this by using ctrl + P and here main character. So I now have two characters but i'm not
controlling one of them, this is because the way that inputs are sent is by a class called
controller. In our case, the player controller. So a player controller will be a class, a
blueprint, that we are not seeing but we are constantly interacting with it and this class is
sending the inputs to any pawn or character that we tell it to control or in this case, in unreal
is called possess. So if my player controller is possessing this character then, whenever I
press W it will move, make it move forward. But, because I'm not possessing this one, nothing
is happening, happening to this character. In Unreal we can unpossess and then possess
another character again, is just a way of changing what we're controlling, but in this
case we are adding the rotation to the controller so we need to use that rotation in order to
move the camera. So here in the spring arm, that is this component, we will go here in
camera settings and use pawn control rotation. This refers to the controller that we were
talking about, and we would press true. Now let's press play, and we can move it side
to side, but also up and down. Now, for my taste I find that, that the y-axis should be inverted
for me to be comfortable, so you can either do it here by, look up multiplying it by minus
1, no, not minus 10, that's too much, -1. Play and it will be inverted, or you
can also, if you want to keep it clean . You can also, here in lookup just put
-1 and then it will also be inverted. Okay so with the camera working we
can then make this movement work. Now to fix the movement, I would need
to know where my camera is facing and not where our character is
facing. Why not use our character? Because it will probably look a lot
better if here we go to class defaults, and in pawn, let's uncheck use controller rotation
yaw. Now if I press play we can look around our character and our character is not using the
controller rotation, but this will mean that if i'm moving, want to move forward like this,
instead of using where our character is looking like this we want to know where our camera is
looking forward. That will be this direction. So to get that direction we will
first make a little bit of space, a little bit, and just like we added some
controller input we can get that control rotation. With this value, I can know where my
character is looking. Now this is a rotation, a rotator excuse me, and we need a vector for the
direction. We can ask here, get control rotation, I want the forward vector for my forward
movement and I want the right vector for my move right. Now I could connect it like
this, and it would work If I press W and I keep pressing
W, it will move forward, right? And every time I move right doesn't matter
where my camera is looking to, it will be still moving right, and in order to show it
better, I can go here in my character movement. I can go to character movement, rotation settings,
and here I will use orient rotation to movement. Just check this and press play and our character
will rotate towards the movement and that looks a lot better actually but we need to do a
little transformation to these vectors because in the case that our character could move in the Z
vector, this is giving me a vector that also moves in the z-axis. How can we see this value? We
can use this useful node called print string and just connect our vector to it. Let's press
play here we see the rotation value if we move our camera, then I'm seeing that Z value
change, and I really don't want it because it can give us some problems later on, so that's
why i'm gonna just delete it. Here in the world direction I'm gonna drag it out
and press make, make a vector, and this one I will split it. I saw that Ii don't
need the Z value, so i just need the x and y value so our movement is always parallel with the
ground floor, and I will do the same with this world direction. Split and x and y, and now
if I connect this vector to this print string then i only gonna get the x and y
values and this should be working fine. now let's just delete this print string
and we have this um movement working just because of organization's sake i i like it if
i have a little bit of freedom with this and also usually stacks things like this
this so it's easier to show more code something like this yeah and it's a little bit more compact and
it's also a good practice to select the notes and make some comments here for example
select everything press the letter c and just type movement input and here below
just c again mouse oh well camera camera input and now everything is good and tidy now that
we have a character that can move around and jump around it will be a good idea to
have a level to test it and change some values so here i'm gonna create a new level new
level let's just use empty open world because it brings some good optimizations
and we have the word partition and we will also be able to use one file per actor that we
can explain what it is a lot later but for now these words should be enough for us especially if
you're gonna be working with other developers but if you're not then you can just new level
an empty level let's make it nice by adding a directional light and it will be good to
have some something to see for example this cube let's just put it in the zero zero and
stretch it a little bit we will change this eventually now if i press play i won't see
anything because there is no light here so i need to add first my light directional light it will be good also to add some
visual effects here sky atmosphere so we have some sky to get rid of this
black void we can also add visual effects and an exponential height fault that's a
lot better if we wanted clouds we can add visual effects volumetric clouds so now it looks
a lot more nicer with this type of lightning objects it will be good to have a space for
them and here i'm gonna put them in minus 400 and 400 and i will copy this value i will
paste it in another one and just add it 100 and i will do the same for the
rest of them i just want to to know that oops ah 600 was too much paste it again i just want to know that if i have if i found one of these in the
map the other ones are near there it is and this one the
same paste it and now it will be balanced 300 also just click on the four of
them and let's create them their own folder here like right click it move it create
new folder and let's just call it lighting yes so it's easier to search for them and well
if i wanted to disable all of them we can do it perfect now this cube like really doesn't
reflect our cheerful character so what we're gonna do is just replace it we're gonna
search for any asset that we can use here content and because i don't really remember where
our assets are we can just use a filter inside the content browser or well content drawer filter
let's just search for an static mesh and here it will show us any static mesh inside the folder
that i choose so here it will change depending on which folder or i can just search in all the
project and we should have floated island m should be fine i believe yeah that that
should be good so let's just drag and drop it maybe it's really too big uh for now should
be fine let's just put it on the zero zero and if we press play we are
spotting wherever our camera is we need to define a point where to spawn
our character so we will use this player here in basic player start you can also just
type here click player start and you can find it this player start will will define the
location and rotation of our character so we can put it like here it doesn't matter where our
camera is let's press play and it will start there great now we can add some assets and tweak the behavior
of this character that it now can jumps but we should really tell it how high it should jump
so for example here i see i saw some crates and maybe it's it's too large right if there isn't another one smaller than let's just reduce its value let's scale it to maybe this size 0.5 like half of the value yeah
that should be fine i should be able to jump this and oh is in case i just jumped the gun you can
move rotate and scale and change this widget by using these buttons or by using the hotkeys
here w e and r so now let's change how much this character jumps i will go to my main character and
the everything related to the movement behavior of this character will be with the character movement
let's click on the character movement and also the search for the jump jumping and falling
here i want to jump twice as high let's just put multiply by two let's press play and
now i am jumping twice as high but let's take in consideration that it is a
platformer so you really need to be very very precise on your jumping so we will go
back to the jumping event input action jump we had jump and stop jumping why did we put stop
jumping because inside this character and let me just return this value this jumping value to the
one before i had you can also search here jump and i'm gonna return it to the default volume so
this stop jumping is here because this character has already functionality related to jump we can
go here to the class defaults and we have jab jump max count and also jump max hold time if you
needed a double jump you can put here 2 press play and now we have a double jump or triple jump just
put here three press play and triple jump we have now for for now i only want one jump but i
will tweak this value called max hold time and this allows us for example if i put one that
whenever i press play and i press the space bar and just release it immediately i do a small
jump but if i hold it it will do a bigger jump so it's it's pretty nice right now i don't really want to hold the space bar like
one second i only need to hold it for example 0.2 0.2 oh that's the max count
excuse me 0.2 let's test it and a little jump would be this one max jump
would be that one right so now i can tweak the jumping velocity maybe 600 should be fine that's a little jump and a max jump should be this one so maybe 0.3 could be
the value that i'm looking for because i want to with a
little jump reach this value this box and with a holded jump i
should be able to reach two stack boxes like this and i don't seem to reach so let's
just increase that that hold time maybe 0.4 almost there and 0.5 who it's
a character that can jump a lot okay that should be fine now with this knowledge we also should
be able to change how fast it should fall right now it's too floaty for me maybe we can
up the gravity scale maybe two or two three and that feels a lot better for me actually am i still able to reach there no but maybe it's
better it was jumping too much for me i believe yeah yeah it's jumping too much i i
didn't really like it that much so let's what happened here oh simulation 0.3
was fine and here max jump one is fine let's just add some jumping or
well let's just test it like this this is a little jump a bigger jump
should let me reach it yeah it's it's fine just a little bit of jumping to tweak
it better where's my jumping here it is 50 should make the difference and now yeah
that's a lot better a lot better if we wanted to change the movement speed we can also do
it here in the character movement we can go to walking and here max walk speed we can
change it maybe to be a little bit faster 80 and now i'm liking it even more now it's looking
pretty good well it's feeling pretty good our character feels pretty good
our camera feels also pretty good and the controls are what any player would expect so yeah that's great the last thing we would
need to do with this character is to make it move it's really not appealing if our character
is just sliding around so we're gonna do just that now and also you can tweak the movement of the
character to your liking maybe you don't want it to jump like this it's fine it's your game after
all so let's make it move around we we will see here we will click on the character press f just
to center it and we will find the skeletal mesh here we can also define the animations and
if we define for example here animation mode asset we can define any asset that
exists for example here should be i don't know idle but this will mean that when we
press play it will be stuck in that animation so what we need to do is use an animation blueprint
so let's select the skeletal mesh component here animation blueprint and right now we don't
have an animation blueprint that works for us this one is probably broken so we also want
to create one from scratch just to not depend on anyone else okay so because it will have to
do with this character let me remove this filter let's go to my 3d platformer folder and
let's just call it this folder characters just in case i have more characters and folder how this one is called epic character
so let's call it epic character let's right click animation and animation
blueprint we already have done let's select this specific skeleton epic character rig skeleton
and create let's just call it animation blueprint epic character and let's open it like i was
saying we already have done a video on the animation blueprints so i'm not gonna cover the
fundamentals here so you will just need to copy what i'm doing here okay so we need a way to
define the states of the animation of this character let's just right click here in the anime
graph you don't have it you can find it here here is also the event graph so here in the anime graph
let's just right click and create a state machine let's just put a state machine and it was add new state machine
let's just call it locomotion because it will be the any motions that will
have my car that will drive my character and i'm gonna connect the result here let's
just double click this state machine and let's create an idle state well let's create
a state first add state and we're gonna call it idle movement oh i'll i'll run it let's just open it and we will have to use this
there should be a blend space here either run let's just add it here let's connect it like
this and this speed let's put it as a variable now let's compile it so the variable exists
and we will go to the event graph here i'm just gonna ask for my character let's
just cast to a character this is just making sure that this owner is a character if
it isn't our character will just slide around but if it is i want to know one the speed and
we can also get the speed from here just get velocity and ask for the length and that is the speed i'm gonna put this here just in case split let's set it up because i'm gonna need
it when i'm jumping set the speed like this let's save this to compile it now if i go to
this tab the animation preview editing values edit preview we can change the
speed and it should reflect the value but right now i'm driving
this value from the blueprint let's just oops let's just remove that pin right now and just move it around to see if my
blend space is working it is working so speed let's just connect it like this
compile it let's go back to my blueprint main character and here in animation well select
the character mesh select animation and in class let's look for our animation blueprint and when
we press play now it should be moving around great now but if we jump it's still doing this so
it's not really working for us let me see if this character has a jump animation it should have whenever we open an animation blueprint we can
check the skeleton of the mesh that we are using the skeletal mesh the skeleton skeletal mesh and
the animations so here i will search for a jump and we have a lot of them jump run jump end loop start jump up we're
just gonna use this run and end so let's go back to our animation blueprint let's here in the idle running we can return to
the state machine like this by using these crumbs and let's create another state
let's put jump start jump loop and jump in and we're gonna connect this jump end back
to the idle running something like this now these are different states let's just fill
the states with animations here i'm gonna search jump and i'm gonna see if this jump
loop does this works should work good enough and what's this run loop i i believe it's the same so
let's just use the jump animations there's here uh this one doesn't doesn't have too much personality to them so i'm
just gonna use the jump up for the jump start in the jump loop i will use a jump up loop and connect it oh jump up is the whole animation oh
excuse me then jump loop is correct here jump loop is the jump loop in jump start
it will be the jump up start yeah this one let me replace this jump up with the jump start and in the jump end we will use the jump up end now we need to end if we press compile it
will show us some error because we are not entering these states there's no way for us to
enter this and these are the transitions rules so for example if i want to go
from idle running to jump start probably i want to know if the player is
in the air so i'm gonna promote this to a variable and i'm gonna call it is in the
air or maybe is falling so if it's in here or let's just call it is falling is in
there falling yeah let's call it this fall and now in the event graph we need to set up that value called is falling it's falling it
is falling or upset is falling excuse me and the character does have a way of
knowing that so we can ask is ollie and we can connect this directly that's
why i needed this cast to the character now whenever this animation ends i don't want it
to loop i just want it to play once and then go to the loop one so let's here in the jump start
click it in the detail panel loop animation and check it so when this end i wanted to
reproduce well to play this jump loop so here in the transition i'm gonna ask jump start this is
the state so i'm want to know the remaining time can use the fraction you can just use the
time whatever you need so jump start here i'm gonna ask if it's less or equal than zero
this will mean that the animation finished then it would play the jump loop and
i do want this animation to loop so this is fine and whenever i touch the
ground here so i'm not longer falling not boolean falling so if i'm not falling then i
will play this jump end i do not want this to loop and the transition to the next state will
be when this animation ends so i'm gonna do exactly the same as the other transition rule
so get an in time remaining if it's less equal than zero then it will enter the next
transition and i will put put it like this the difference between this and the time
remaining and the fraction remaining is that the fraction will give you a value
between zero and one and this one will be between 0 and whatever the length of the animation is so now let's compile save it press play and i
can move around if i jump my animation will work great now keep in mind i have skipped some
explanations for example what is a blend space what is a state machine we go in detail with
these topics in our animation blueprint tutorial it's a little bit updated because unreal engine
5 released but the fundamentals are still there now with that out of the way with the animations
out of the way let's just close everything related to that and let's save my main character and
also let's save this map file save current level let me add my 3d platformer and if you are losing
track of your folder you can right click it well we can change the color we will see it after
we save this so let's create a folder called maps and here i'm gonna put character test map let's just save it and like i was saying i lose track
of my main folder constantly so let's just set the color i will set it to a blue
let's put it okay and now we can find it easily maybe blue doesn't pop up that much we
can change it to any color you would like and with all of these out of the way we can start
creating mechanics suitable to the platformer genre for example pickups it will
be very probable that you will play around collecting stuff maybe coins
is whatever we need in order for my my game to have some sense of progression right
so i'm gonna create a pickup now let's create first a folder inside the core because
if our game doesn't have pickups then i will probably won't be able to win okay
so let's just click a folder here and call it pickup open it create a blueprint class let's just
create an actor call it blueprint pick up double click it create a static mesh and
it will be blank so select the component search for this there should be a
coin or something that we can pick up here of all the assets collectible yeah let's
use this one for now so we have this collectible and now if we can bring it to the map
it can be like this let's press play and nothing is happening right so what we
need to do is some interaction we want to collide with this pickup so let's click on
the root component add a sphere collision and let's call it pick up collision and i'm gonna maybe 60 would that be too much that should be fine i'm
gonna set it to only collide with my character and this will be here in the
collision category collision presets overlap only pawn a character is a type of pawn
so this will work for us overlap on the pawn and whatever it is overlapped here if i go to the
events category at the end we have an event called component begin overlap let's click it and for now let's just compile save it and
if something overlaps it especially well if a pawn overlaps it we will just destroy this pickup
compile save let's press play and if i overlap it then it gets destroyed and it looks like i
pick it up right so that pickup is working fine for now with the pickup created we can start
duplicating this one by holding alt and dragging the blueprint and if we hold alt and shift
we can also move the camera so we can have a lot of pickups around the map and i'm not liking
these hard shadows so let's add in it was it light skylight and drag it here so we can smooth those
shadows and i'm gonna add it to my group of of lighting actors let's just copy that paste it here at 100 and add it to the folder that already exists
lighting okay that's better that's a lot better actually and we were talking about at the start
to that is important to have the flow of the game as fast as we can so having this in mind right now
we just have the movement the camera the controls and we have something to do
which is pick up this step if we wanted to have an ending to the
game we would probably need a goal so in order for us to have this goal we need probably
to reach somewhere and whenever we reach that place then the game will end like or well the
level will be beaten so let's create that goal now let me search for a good mesh for the goal it could be a kind of door this one this
should should be good yeah yeah that that seems really nice actually so let's use this
door this door this wall yep let's use this so let's create the gold blueprint in the
core folder and let me remove that filter because also if the goal doesn't exist then what's
the point of the game right so new folder goal blueprint class actor because i just
want a blueprint to put inside the map and here i will call it blueprint gold i need some something to
represent it so let's add a static mesh component find that door wall door or just door door does
this works nope that's not it door kit what this one and i'm gonna put it in the middle someplace like that x positive
is the forward so let's ctrl c and rotate rotated first
and then move it to almost the middle that's fine we also need a way
to interact with it so we will also create a box collision it will be pretty similar
to the pickup so this one will be and i don't want the box to be
attached to this static mesh so i'm gonna drag and drop it on top so i can
detach it this box i'm gonna reset its values and now i'm gonna increase the extent maybe 100
here should be 800 almost yeah that's fine and 200 and i'm gonna elevate this component
like this so whenever i touch this i win now i also need to change the collisions i don't
want to overlap all dynamic objects i only need the phone on and here begin overlap for now i'm
just gonna show a message print string saying that you won let's save it compile it and i'm gonna put that
goal in my level and now i can do some stuff here pick up some stuff and then go to the goal
and it will say that i won i need this to be in a place where it is difficult to reach but that
will be whenever we create the map for the game with the goal and the pickups we have already a
simple game flow to make it a little more official we can go to the game game mode framework
game mode we can open full blueprint editor here custom event to create something
that will trigger whenever we tell it to and we're gonna call it win the game
or pass the level just win the game now with this i'm just gonna copy and paste
whatever we have here i just cut it paste it here you won and the gold the only
thing that it needs to do it's get the game mode and ask if it is using my gm my 3d platformer game mode and tell it
that yeah win the game this will allow us that if for whatever reason we don't want to win
by the goal anymore we just need to delete this and if whatever it happens after i win we can
change it in the game mode and any object that tells the game that we already win
will execute whatever code we have here so it's a more clean way to manage our game
flow and why did we want to have a game flow so fast because now we can see if the game is
working we can start tweaking the values maybe these jump values are weird or the animations not
working or maybe it's too simple the game just you just walk here but these are decisions that can't
be made now we can start testing any mechanic that we had in paper and just adding it
to a working game will give you a better perspective so for example right now my game is
very boring because it's just a plain surface so we would need to add some difficulties
some obstacles for example here we could have a static mesh already have it
here floating iceland maybe s which one is smaller they are the
same size so let's just use this one let's put it a little bit more small and i'm gonna put it like this and another one here and i'm gonna rotate it so it doesn't look like
it's the same and i'm gonna put the gold there and i don't need a copy of it i just want to
move it with shift so my camera also moves and i'm gonna press end so it snaps to my
floor now if i test the game i can pick up the coins and we really need to do some
overhauling some overhaul there so it it works better and now i can see that i won also
i can change something that is really bugging me is those animations i don't really like
them that much so i'm gonna go to player no excuse me characters epic character animation
blueprint jumpstart will be the running one jump run start i'm not gonna delete this for now
in ch in in case i change opinion jump loop will we the jump run loop and the jump end will be the run no not the run
start the run end let's save it compile it play it oh and this is oh this is not working
properly because the end is looping and also i should remove the jump start loop
so now it's a lot better i like this a lot more yeah perfect now no it's it's better with that animation polished let's save it here we should do something about these pickups
why because there probably will be more than one type of pickup pickups is one of the most common
elements in any platformer game so probably we will have coins keys power ups etc so in order to
create another pickup we could just copy and paste this code but whenever we need to make a
change then it will be really difficult to keep track on which pickups have the change or
fix in the code and it will be a mess if you have more than one or two so we can use a concept of
programming which it's called inheritance this will mean that for example my blueprint pickup i
can right click it and create a child blueprint and this child will inherit all the traits of
the parent this one i can call it blueprint coin and this blueprint coin let's
just drag and drop it here play it and it will work exactly as the parent if i needed another type of pickup for
example pick up another child blueprint e i can move it here but this
doesn't look like a key right we can make this change if we right click it
edit it or here double click it and in the static mage change the static mesh i will change
it there should be a key here key here it is key and this key is a little bit weird it's not in
the center but we can change this pickup collision like this so it is a lot more centered and now compile
it character test map i have my key here and it will still be working exactly
as the parent which is a bonus because now we just need to change the way
the parent works and everything else changes in the case of the coin because i don't want to
change the c value every time i want to to put a coin in the map i don't want to do this every
time i'm gonna go inside the coin the static mesh i'll put it in how much did i hear in the
key did i move this pickup college collection 140 let's just copy it coin also 140
and the collision also 140 compile it and now every time i drag and drop a
pickup a coin excuse me it will have that height which is better than just putting
them and moving them in the c value so i'm gonna delete first every other pickup
because these are using the base pickup and you probably don't want to have the base
pickup the parent pickup anywhere just the child's and i will move these childs to another folder
outside of the core the core is the base classes so here in the my 3d platformer
i'm gonna add a new folder called picaps and whatever i had in my
pickup folder i'm gonna move it the key and the coin to the
other folder called pickups and after moving them here in the base
pickup the parent i'm gonna double click it and in the event graph i'm
gonna create a custom event and i'm calling it picked this up for now we're not gonna do anything
with it just call it here whenever i overlap it and i'm gonna do something like this picked pick this up and then gonna
destroy the outer so this will be called whatever we put here will be
played before we destroy the actor now that we have this setup we can go to the coin
or to the key and add new functionality for this i don't really need the gold anymore so i'm gonna
close it and the game mode also gonna close it just avoid having some clutter here and in the
coin i'm gonna go to event graph i'm gonna go here in my blueprint panel functions and
i'm gonna select pick this up this will be an override of the functionality that you
can find here and in the coin maybe i want to put a string in the in the
viewport saying you got a car or one coin so now let's press play and if i pick up the
coin i get one coin and if i pick up the key it doesn't have that functionality i probably
also want to play a sound whenever i pick up this coin so i'm gonna use play sound 2d
because i always want to hear the sound and there should be a coin
sound somewhere here it is coin let's press play here is the coin and the key
doesn't have any sound now if i wanted to do the same thing with the key i could just copy and
paste this but probably in every pickup blueprint i will want to have a sound play so what i can do
is put this node or any type of code that i want to use in every pickup child and i'll just cut it
and i will paste it in my blueprint pickup here now if i do it like this if i press play my key will sound but my coin
won't why is this happening because in my coin i have not tell it to execute the parent code so
i'm going to do that by first making some space here in the event pick this up right click
it and add call to the parent function this will will make it so whenever and
i can double click this whenever this is played first we will run this part of the code
and then i will run the string let's press play it stands here and it also has sounds here now
i want to change that type of sound so here in the pickup i'm going to make this sound a variable
and a variable is just a little box where we can store some information we need to define the type
of variable if we just right click it and promote to the variable this is already defined it's
just a sound base let's compile it and for now i will clear this value because this
is the base class the parent pickup and in the coin i will go to the class defaults
and here in sound i will change it to coin save it and compile it and in the key
i also going to go to close defaults and in sound there should be also a key
type of sound here e let's save and compile let's press play and now if i pick up the
key it's a different sound than the coin now let's add some specific functionality
for my coin pickup i do want to show how many coins i have and i will do it in my main
character i won't be able to create a widget i could do it but it will take me a little bit more
time so what i'm gonna do is here just add a text render and i'm gonna put it on top of my character
this text render i'm gonna add it to my spring arm and i'm going to reset the positions and i'm gonna put this right
on top of the character i want to see if this will show the text even if i
rotate my camera and it does so it's working good enough i'm gonna put it like this and i'm gonna
rotate it a little bit first let me change the or horizontal alignment center text text
button is fine and now i'm gonna rotate it 180 text it may be a little bit
too high something like this and now it is working perfect
i want it to be zero for now and this text will reflect the number of coins
that i have so i need to store somewhere the number of coins i'm gonna save it in the main
character which means that if my main character for some reason gets destroyed i will lose
all the coins if i did not want this kind of functionality i could probably put it in another
class maybe in the player controller but that is for now out of the scope of this tutorial so
let's create a variable for this number of coins and let's set up its type i don't want to store half a coin so i don't need a floating point
number i just need and a whole number an integral and compile it save it number of comments
zero i will have a function here to add a coin and what this will do is it
will set my number of coins to the current number of coins plus one plus zero plus one and you see that i just
drag and drop this variable if you just drag and drop it normally you get this message if you
drag and drop by holding ctrl you get the get and if you drag and drop it
with the alt you get a set now with this my number of coins will be
updated but i also need to update this text so i'm just gonna drag and drop it
i'm gonna set text here it is set text and the text i'm gonna set is this one and i can define the minimum integral digits
maybe i could put two here so i could press play and for now let me put the text in 0 0 and whenever i add a coin and i can
choose to test it like this at coin in the begin play so after i press play i
will add a coin then it will have zero one so it's pretty cool let's compile save it and
now we need that whenever we pick up a coin we want to call this add a coin we will do that
we will do it a simple way if we have some time i can show you how to do it another
way but for now it is easier if some blueprint communicates to another one this
is called blueprint communications there are three types of the most common blueprint communications
this what we will do is a direct communication and for any type of communication we need
the sender the receiver and the message so here the coin will send the message message of
uh you need to add one coin and the receiver will be the main character so in order for the coin
to send the mesh message it needs a reference to the receiver to get the reference of the receiver
we can go to the blueprint pickup parent and here in the peaked pickup collision to begin
overlap we has we have this other actor and this is the other actor that is colliding
with this blueprint over that component is the component inside this blueprint that has caused
this collision in this case the pickup collision the other actor is the other actor that calls the
collision in this case the main character other component is the component inside the other actor
in this case it should be the capsule component and while the other ones are for more um special
types of collision we can get the results of of the specific the impact location normal
impact normal etc but this is out of the scope so i need to send this other actor to my picked this
app event so let's click here let's add an input and this will be of the actor type actor object
reference and i will put it actor that picked this and for now should be fine
i need to connect these two and in my coin i also need to connect these two and with this actor i can do something like
this i can ask if it's my main character custom main character and if it is then i will just add a coin with this if i press play i add a coin and
it is added and let's add more coins here and see if it is working
and it is so that's awesome with the coins working we can now pay attention
to the key that right now is not doing anything what i want to do is have some gates that
will be opened only by some specific keys and it will depend on the type of key that it is
so we will open this blueprint i will use ctrl e and here i need to save a value of the type
of key it is for example it is a blue key red key whatever key it is so what i'm gonna
do is add a variable i'm gonna call it keytype and here i'm gonna select as a variable type gameplay tag and this could be a new concept for a lot
of people so what is a tag a tag is some text that i can set up in my project
settings let's go to a break settings here gameplay tags and it's a easy way
to compare strings or well categories whatever you need you can put here so for example
if i want to ask if my player has the blue key and the red key it will be easier to use gameplay
tags than having to create for example a string here and then comparing strings so in my case i'm
gonna go here to a project settings gameplay tags add a new gameplay tags and i
will put here e yes add the tag here i will have all my tags i can add a sub
tag here key dot blue add the attack and also red for now that way whenever we have to blue the blue
key it will open all the blue gates and if wherever we have the red key it will open
all the red gates and maybe if we have a purple gate we need the blue and the red key
something like that maybe now with this setup i can go to my no not to my coin i can
close my coin for now i can go to my key compile and save it and in my key type in the
details panel we can change the default type right now it's a blue type of key so i can put here
blue by default so compile save it and whenever i want to pick this up let's remember functions
overwrite pick this up if we want to play this sound we also need to
call to the parent function and now here i should give the key to the
actor that has picked this so i'm gonna main character like we add a coin we can get a key and the input will be a gameplay tag and we want to save it in a collection
of gameplay tags that we can get so here is this will be the key to obtain and to save it we need to create a variable like exactly like the coins
but this one is is collected and this can't be just a gameplay tag because if it was a gameplay tag we can only
have one value either blue or either red so i need to change this to a gameplay tag container this will be a
collection of any type of gameplay tags okay so compile and save it and here key
is collected let's get the collection we can gameplay tags add gameplay tag and
connect it like this this will make it so we are getting the key and saving it in
my character again if this character is destroyed then we lose all the keys so maybe
this isn't the best place to save the keys but for now we will do it like this now blueprintkey
is actor i need to know if he's the main character and here we will get a key which is the key that we want to give the
character is this one key type this one save it and now let's just go to the main
character to check if this is working let's print the keys that we have collected it was debug get debug string from
gameplay tag container let's press play let's go to the key and it says key
blue now if i wanted to add more keys then we can change these values and
add more keys here in the project settings now we need something to use the key on and we will create some gates that will depend on
the type of key so let's go to the content drawer in the core folder let's
create a new folder called gate let's open it let's just put a blueprint
class there an actor is fine blueprint gate let's open it i need first the static
mesh or the gate there should be something that i can use here if i
type gate large gate i need just a gate or here gate and add static mesh and it's fine
if it's attached like this this will be force field because i just saw the force field static
mesh that i wanted to use force field here it is and now i have this force field and it's a blue
type of force field so if i use the key the blue key i should be able to disable this so i'm gonna
put this key this key this gate on my on my map and let's make sure that the gate is pointing the
right way remember x positive is forward so i'll select the gate static mesh let's call it static
mesh gate and i'm gonna rotate it a little bit so now it is facing forward now yeah perfect i need some
way of interacting with this because right now it's just blocking my path which
is good so the way i will have to interrupt with this we already have seen it let's click on
the default scene root add a box collision box collision i'm gonna call it gate interaction zone this will be a trigger it's it will be almost the same as the overlapped
pawn but it will have some presets here a little bit changed let's not worry about
that trigger will work so gate interaction zone collision preset trigger let's just make
it a little bit bigger 100 no that's maybe too much or maybe it's enough this 200
also no that's too little 300 and 200 here and now in the c value when i put
100 that was too little so let's just put it up a little bit perfect
now i have my interaction box and what i'm gonna do with it is again use that
on component begin overlap here i will check if first whatever i touched is the
main character so the other actor let's make sure that if it is the main character and then i want to ask what type of keys does it
have so i'm going to ask here yet it is collected and i want to compare with the type of gate
that it is this one is by default is a blue gate and i want to see if you have that correct
key so what i'm gonna do is create a variable that will let me save what type of
gate it is so variable let's put gate type and here gameplay it won't be attack it won't
be a container it will be a query because we will see in this collection if you have the type
of key that i'm setting up here in this query so let's compile and save it gate type gonna put
edit and i'm gonna here select any tags match and what tags do i need to
match is the type of key in this case blue for now
so let's save and close it and now i can compare if this gate type get
game type gameplay tags ah here it is make gameplay tag query oh excuse me it's not
it was not the make it was the comparing this one does container match tag query
so this is the query this is the container and if it matches let's put a branch node here if
this is true it means that in the key is collected i do have the same type that i have in the query
which is blue and i want to create a custom event just for clarity's sake and for cleaning the
code here this custom event will be open the gate and if this is true i will open the gate
for now opening the gate will mean that the force field i will disable the collision so set
collision enabled to no collision and i will also hide it set actor no set hidden in game
i'll set it to true so with this intro i will press play here i cannot pass
if i get the blue key now i can pass if we see this again it is looking a little
bit too rough around the edges because it just disappears and what i can do especially with
this force field i already checked the material here i can double click here in materials
and it will open this type of material and it already has a value called
opacity and if i check click the check and then move it around i can change the opacity
of this element which is really really cool so this is something that we can modify
in blueprints so for now i won't save this but in order to modify a material parameter
which is that opacity that's a parameter i need to first make it a dynamic material so i'm gonna
do exactly just that begin play i'm gonna create dynamic material instance and this one already
has the static mesh force field selected it will reflect this name so i'm just gonna use use
it i need to make sure here i missed my static mesh that the material in this index is 0 here
element index 0 also and the source material will be this one so i'm gonna find it like this
and i'm going to assign it here with this arrow and the only thing i need to do now is save it as
a variable and i'm going to call it force field dynamic material and well reference because we are referring to this
created dynamic material instance now when we open the gate we can set up instead
of hidden in game we can get this dynamic material set a parameter in this case is
a scalar parameter value because it is just one number it's
not a vector it's a scalar i will put it to zero and this is opacity and
i'm not sure if it is in all caps or not so let's check it again material here this is the name
we can right click it and copy display name and then indicate paste it here let's
press play let's see if it works and i need to have the key it is working but
now with this parameter i can create a little animation with my timeline i'm gonna type
timeline at timeline this timeline will be course field opacity or it could
be timeline opening the gate now what is a timeline is a special node that
can play a curve so how do we modify the curves let's just double click it the length i want
it to be one the track i need a float track we can have vectors events or colors i just
need a flow track this will be the opacity and here i can define the curve we can right
click and add the key or we can shift click and we can also add any key the opacity
will start in the time 0 with a value of 1 and it will end in time 1 with a
value of 0. we can use these arrows to frame those keys but this is
the curve that will be played whenever we use this node so we can close it and
here we will find that my timeline has a new pin called opacity whenever we open the gate
we want to play that timeline and every time the timeline updates i want to update the
opacity value like this so let's play press play let's get the blue key and now we can see the
force field disappear which is pretty pretty nice now that we have the pickups the keys and
the gates working it should be a good idea to know how to create more keys more pickups
or well another different type of gate so for example we will do this approach
let's say we don't want to create more keys we could just like we did with the pickup where where is our key folder or pickups folder
here we can just create a child grouping class and change the values or if we open the key we
can hear key type open the eye of this this means instance editable which means that any instance
of this actor of this blueprint that i have in the map for example this is an instance if i
duplicate it i have another instance i can make it change so here edit red let's just save it
and now if i press play i get the red key i cannot open this blue gate but if i had a blue
gate a red gate excuse me i'm gonna duplicate this i cannot change the value because i
have not make it instance editable so i'm gonna go to the gate here
in the query i'm gonna open its i this may makes it an instance editable
gonna compile it save it and now in the map i can edit this and here no i don't
want the key blue i want the key red and i will save it now i can press play i get the red key i can't open the
blue one but i can open the red one if i needed both edit edit and blue and red let's
see if this is supporting both let's press play if i get a red it is still working because it now
it will open with any of this one the red key or the blue or the blue key the blue or
the red but we can here instead of any tags match all tags match and now i can
add the blue on the red save and close press play if i pick up the red key
won't work but if i pick up also the blue key here i know red and blue that one opened
with the blue and this one open only with both now we have changed the values here but we
have not changed how it will look so here this is remember the red key with any blueprint i have
access to its components here in the details panel these are the components of this blueprint and
i can go to the static mesh and change this material so instead of power up a there is already
a red material so let's put power up a3 and that is a red key i did not have to create another
blueprint that will only change the way it looks for the force field in this case let me make it so
i only need the red key like this save and close i can also check the force field this is the
material instance and i can change the color so for this one and where is it here
it is i will browse to it i will duplicate it call it force field red gonna
open it and change its color multiplier so this one could be this red like this okay and now i will
use this red value here in my map force field there should be a force field red here
it is and now it is it will work as as expected but it seems that it didn't save it
for some reason let's just save this if this doesn't work then something
in that material must be changing my my color multiplier not to worry we can
also go to the gate create a here also in the when we create the dynamic material instance we
can use set material instance to change this color multiplier let's copy the display name
let's put here parameter a set parameter and in this case the parameter is a vector
because it is a color so set vector parameter now i will put the name color multiplier and this value i will make
it a variable this variable will be gate color gate force field chord let's be a little more
specific it's it's good for your variables to have a very easy name to understand understand
if we just created variables that ah this is s and this is x and this represent the velocity
and the location it just doesn't make any sense later on when you check the code again
so here this color i'm gonna set it up the same as this blue so i'm gonna copy the
value and here i'm gonna first compile and save paste the value perfect compile it and make
it instance editable this way i can return the this gate material didn't work that
approach so let's just reset it to default but we can here instead of selecting the
components we can go to the blueprint itself and in gate force field color i'm
gonna change it to the red one if it's not changing is because this code is
in the begin play so we won't be able to see the change until we press play
but now we do see that change so maybe you can do a combination
of both if you want to also see it and i'm gonna copy this red copy and
i'm gonna paste it the blueprint paste it here it's almost the same so we
press play we get the blue one this open this doesn't open we get the
red key and this open and the other does before building the gameplay map i wanted to
polish a little bit the celebration part because right now if i reach the gate like this is it
just says you won and it doesn't look really nice so what i'm gonna do is first the
main character needs to save a state a celebration state so let's create a
variable let's call it is celebrating and i could do it like this but let's
just say that they're me more they my english is failing they may be more states
that you could have or that you would want to have so a better way to implement this will
be here creating a numerator inside the layer and here i'm gonna go to the category blueprints
enumeration i'm gonna call it e character states and here it will be the first value none second
value default and the third value celebration creating a celebration here and yeah celebration
blueprint main character is celebrating let's just not call it that let's call it character state
and here let's call it the type should be e characteristics this one by default it should be default perfect and now we should have a way of
entering that celebration state so let's go to functions enter deliberation and this
will change the state to the celebration and also it will spawn and ayagara system system at location the location i know i have this celebrate so let's
test it like this get actor location and also get actor rotation like this and let's just test it how should i enter this
in this celebration well you should only enter this state if you win how do we know if we
if we won in that game state so let's open game state 3d platformer you want we can leave
the message but now i can get the player character cast it to my player main character and here it
will enter the celebration let's press play let's just let's just speed run
this we don't need to walk all the way here we can just right click here play from here we will enter
it and we have that celebration and that should be follow me around so let's go here instead of a
spawn system at location spawn system attached the template should be celebrate the attach
component should be this capsule component and the location tab type should snap
to target and keep the world scale let's press play and let's speed run
it like this play from here and now it is celebrating i need an animation
let's go to my well let's save the game mode this is already done let's go to the animation
blueprint let's select the skeletal mesh component double click well here a nim
class search it double click it and now here in my locomotion i can
have a state of celebration celebrate and i will only enter if the character state here is and this should also be character state and i don't know how to type here it is if this is equal to celebration it will be true and it
should enter this animation let's copy that and if i need to leave this this
state otherwise i will get stuck here i can do the opposite if it is not celebrating so is that not boolean not the other
one the other one is a comparison so if it is not celebrating then
we return to the normal behavior we press play and let's not
forget to do this play from here now it is well it is not happening
nothing is happening because i didn't add first i didn't
add the animation celebrate should be any of these ones i believe let's just put this one and also i have not set up this value so i need to
go to the event graph i need to get the character and here i need to do another cast and i
can copy and paste this tri-get pound owner as to main character and ask the character state and set my
character state with that character state like this and let's not forget again play
from here and now it is celebrating it is looping and i can move around this
shouldn't be possible so we can add a little check here in the event graph let's just close the other
functions and in the movement input i can ask if it is celebrating but what i'm gonna
do is create a function called can move and here this function will return
a value a boolean value return value this will be a pure function and we will
see what's the difference in a minute and i will only be able to move if my
character state is equal to the default one this allows me to add more checks if i need later so can move i'm gonna use it here now
the difference with a pure function and a normal function is that the normal function will
look like this and can modify the values inside the pure one looks like this and will only
return some value after calculating something usually a pure function won't edit
any value of the variables inside it you can make it do it but usually it's not the
way so i will copy and paste this can't move and now if whoops if we play from here we go here and now i
can't move even though i'm pressing w s d great one thing that i noticed while i was testing
this is that what happens when you fall from here you would need to respond somewhere right well
we can create this little response system easily first we need to have a way of knowing where
should we respond so let's go to the gameplay well to the game mode excuse me game mode and
let's save a variable called respawn point and i'm gonna put it as a transforms because
a transform will have the location rotation and scale now we need to set up the first
respawn point point and that will be the player start this one so here in my game mode and at
the beginning play i'm gonna search for the for the player start get actor
of class there should be only one unless it's a multiplayer game where there are
multiple player player starts but usually in a single player game it's only one so here get
actor from class player start gonna get the actor transform and i'm gonna set my respawn point now we have this respawn point we need to
know when the character falls so let's create a blueprint that will help with this here
in the core there should be a folder called respawn system and here will be blueprint class
an actor this will be a height kill volume and there is already a volume
like that it's called qc volume that we can put here and
then if this is big enough it will destroy our actor but we really don't want
to destroy the actor we just want to respawn it so check you can check how it works it just destroyed
the character we don't want that we don't want to complicate ourselves too much with it we just want
to respawn the character or just teleport it here so that's why we're creating our
own blueprint height kill volume let's just call it height respawn and let's open it we only need a box collision and here we just need to overlap only the pawns
excuse me overlap only pawn and begin overlap when we touch this box what we are gonna do
is just teleported the character the actor we can check if it's a main character or not
for now i'm just not gonna bother with it we can just teleport it where do we want to
teleport it to where the game mode tells me so here we will cast it and now we can get the respawn point
get respawn point we can split it and we have the location and the rotation
that we need let's compile save it play it and we haven't added this to our map so it won't
work height respawn volume gonna put this one here and if you want a better way to
increase these values we can go to the top and now we can make it a lot bigger by
scaling it or by changing its values for now and by changing the values i mean here going to
the components in this box component we can add this box then maybe to 100 but i will leave it
like this i i just want to scale it up or down something like this to cover everything remember
that our character can be here and jump that way now let's go back to our perspective let's
press play and whenever we touch that we respond wherever our respawn point was now we can have
multiple respawn points that we can add and we would just need to change this value this is what
we usually call a checkpoint so let's create one we don't really need this height respawn
volume anymore we don't really need this animation blueprint also
the main character probably we do so let's create that checkpoint here
response system checkpoint is also a part of the respawn system so let's add the
blueprint class here actor blueprint checkpoint and we need a static mesh as always and we need to find i don't know
if there was a checkpoint here no let me remember which assets do i have at hand this could be it button ring and the button and if i press the button there is a
checkpoint yeah that's seems cool enough we have the ring here we can select the button
and this makes it a lot easier and here we select check the press on the add button and here
you can check that static mesh has in parenthesis the static mesh that we have
selected in the content drawer so we have the button there pretty
good pretty good so now we can do something with it for example in the
defaults in root let's add a box collision and with this box collision let's
just modify some of its values 100 and here maybe 50 and 50. could also be a capsule doesn't matter but with this this will also be a trigger let's
go to collisions trigger and begin overlap whenever my character overlap this i want
to update the respawn point in my gamemode we could just get gamemode cast it to my game
mode my 3d platformer and from here we can set the respawn point but it is a lot cleaner to have a function
here in case we need to do something else after reassigning the respawn the respawn
point so i'm gonna call it update respawn point and here we just set it like this
and as an input i need a transform now in the checkpoint we can just
call update the respawn point we need a respawn point that transformation and
because i don't want to make some calculations to know what is this point because this static
mesh has a zero zero but it won't i can't spawn my character in the zero zero because otherwise
my character will be like this stuck in the floor so to in order to avoid that
we can have a little arrow component and this arrow component will be on the
root do not make it the new root just attach it and reset anything that it has here and it
will be like this something like this maybe that should be working compile it save it
and in the event graph i will need the arrow let's get the world transform otherwise this component will
give me the relative transform and the relative transform right now is 0 0 110
but the word transform will depend on where do i put that checkpoint so let's use that checkpoint
checkpoint i can find it find it excuse me browse to it here it is let's save and
compile it and now we can go to our character test map and if i fall through here i
respond there if i go here and then respond here i'll respond in my butt i should be able to make
this button color change so what we can do will be to change the matter the material here there
should be a lot of bottom materials bottom one here we have blue and green so here maybe after i
update my respawn point i can button set material and i can assign it the red one and
oh let's use the green one press play and now we can know that that respawn is activate now you will find it that
let's say we duplicate this i activate this checkpoint i fall
down it works i activate this one i fall down it works but the
other one stays active we can we can fix that if in my game mode in the update
respawn point i also am sending the checkpoint reference and this will be a checkpoint and in this checkpoint reference
i will save it promote to variable call it it was checkpoint reference is fine but
i'm gonna call it current checkpoint reference i'm gonna set it like this but
before setting the reference i want to make it go back to
the way it was before so here i need to tell it to go back
to the way it was before in the checkpoint i will create a custom event return to normal and what this
will do is just set the material to the other one which was button a like this and here in checkpoint ref i
should send this blueprint or self can do it okay let's call it self here self
get the reference to self and connect it to the checkpoint reference if it doesn't let let me
is because i have yet to compile it now it should let me self-object reference is not compatible
with checkpoint of object reference why not dude let's just refresh this node
refresh it still not compatible what let's just create this update respond respond point and what is
this and itself is not it but this is a checkpoint oh maybe maybe maybe
it was because this value we had two checkpoints yeah for some reason there was two checkpoints
i'm gonna select the second one and i'm gonna compile it's gonna throw me an error here and i'm
just gonna ignore it for now is if this is what now it's correct yeah for some reason i
don't know why it created two checkpoints so it could happen now i'm sending the
checkpoint reference i have a way to return to normal so in my game mode here this
checkboard reference let me delete the last one i'm gonna promote it to a variable call it current checkpoint reference and before before i set all of this up i'm gonna
use a sequence here sequence is a node that can let you organize your stuff pretty easily and if you don't like cables you
can also get checkpoint ref this is the same as getting it through here get respawn point
this is a good knowledge to have and i'm gonna call this new respawn point so it's easier to to
know which which one i'm getting get new respawn point now i know the difference between these
two perfect and before i do this i'm gonna check if my current checkpoint is valid and if it is valid you can do it like this
or you can do it with the macro like this but if it is valid i'm gonna return it to normal and with this code we can save compile
it press play seems i have an error here what's the error a spawn location
it change compile it let's checkpoint i have to check points what oh there exists another checkpoint the
one that comes with the hour of code we could just ignore it just just ignore it
ignore the the error message i should even delete it yeah i'll delete it so you
see it's it really it's not important and it's been referenced by this the
reference for the date okay let's press play let's go to my first checkpoint it works last
checkpoint the other one returns to normal and it is still working now that we have all the built-in blocks
let's create a map that can use them so i will create a new map new level empty opt-on
world create and well i'll save it save current level and this will be the level one i will use the modeling tools to
create a prototype very very fast and where is x positive here it is let's say
we start right here on a big platform and this is just pulling and pushing push pull i'm just using q and e to make it
faster and then it will be a quick jump here yeah like this i don't want it to be
too hard so let's put the corner mode select these two corners and q
and e to make them a little bit take them a little bit down
now press done let's continue something like this maybe now you need to jump here now i don't really
know if you can make those jumps so it's a good thing to test it so put complete we need um where is my player start put it here we can play now
but it will be everything in black so let's add those lights so what
we need is a directional light to get better shadows the skylight what did we add also visual effects sky
atmosphere what else our clouds there they go and the exponential hyphen a lot
better now let's try it let's test it this should be an easy jump very easy jump
this one also i missed that but is it possible to make it from there should be but i
want to make it through an easy jump ah just a tap jump and doesn't seem to be
possible so let's change it a little bit because these are the first
jumps come on should be easy slide forward corner mode and let's see
if that that makes it a lot more easier a lot more easier perfect now what we need to
do is introduce the first double jump double jump and hold jump i mean we need to make it
so the player learns that you can hold the jump and that it that will be
something that will be needed so first this should be an easier kind of jump
that you just press once and you just get on topic of on top of it let's go back to the cube grid
grid in our modeling mode and then let me just select this part 2 3 and now you shouldn't get any type of option
otherwise our player will feel lost so the player will try to jump and sooner or later
it will have to hold the space bar it will start making sense like it doesn't this should be supposed to to be easy easily jump over
but the player won't be able to do it until it learns well until they they learn to hold the jump
and there are not a lot of other places to go so it's like a mandatory learning without telling
them that they will learn this i'm not really a big fan of games where you need to put a lot
of cues or signs telling them what to do but for me this should be fine i
need some kind of platform here and here this zone will be like the end game why because i will
put the gate where's my gate here's my gate here and i will require the player to have let's
set it this gate type gate type to alt tags match and we need the blue and the red save and
close and for the color i will choose a purple what kind of purple it will be not
really sure well i can tweak it later but whenever i press play this should
be purple it's not a red it's not a blue purple fuchsia i re i'm not really good with
colors but here you should be able to see the the goal so then we can have
some backtracking to get to it so here i will put another kind of room and the goal just like that now we need
to do some more platforming so we should be able to pick up any key and start going through platforms and gates and pick
up some coins so the game feels a lot more fun and i mean this is a really straightforward
map so what i will do is just prototype a little bit and i will speed it up because i already
told you what would my thought process will be i will speed up this part so you don't get bored
with me playing around with some level design here i'm just trying to block out the
level trying to get the distances right trying to make it a little bit
interesting i will make two branching path one to get the blue key the other to get the red
key i believe that i put the gate in purple so i need both of them but that would mean i would need
a red gate somewhere so it makes sense like oh you get the red key and the blood key and it gets
combined so i didn't want to add another path to to the level so i just put the the gate back
to red so first i need to go through the left side to get the blue key and then in the right side
i get the red key that will lead me to the go and as you have seen i'm mostly
testing the scale the distances trying to make some interesting shapes and it's good to know that everything that i do
here later on i don't really need to follow it like very strictly is just to get an idea
of how the map will look how the map will be managing its distances and well
here i'm playing around with the corner corner tool to make some ramps and i will notice
that if i try to go up that ramp the angle is too steep so i need to later change that and again
even if it later doesn't fit it doesn't matter because whenever i start decorating the map with
props then it will be easier for me to know the true scale but at least with this part of
the process i know how large the map will be i can get a sense of the mechanics that i'm trying
to teach or that i'm trying to use in this case this last part is all about jumps that
are long or that you can easily miss and the other part the first one was precision
jumps that you really don't need to hold your space key but you need to be a little more careful
with how you're jumping if you jump too much you fall down if you am too little you also fall
down and here well i change the key to a red key and the gate pulse so it is it is
easier for me to finish this level i finished the blockout but one thing that i
should really mention is that whenever you open the level i close the project recently let's just
open the level one you need to have this window and word partition word partition editor otherwise
you will see everything blank and then here you will select these cells and right
click it and load the selected cells this way you will have for your
map and well if you create a much bigger map then you can choose
to just load some part of our map so here i already tested it it's working pretty
fine and i just wanted to add some gameplay elements for example that part is is easy enough
but still if i die here and i have not put my my height with spawner so it would
be a really good idea to do it where's score respawn system height and i'm gonna
put this here gonna go to the top perspective and just make it fit with the level and be sure to overextend this just in
case something sends our character flying and you really need to have this collision and it would be a good idea to increase the c
value a little a little bit just in case the velocity is too high and you end up skipping that
the trigger shouldn't happen but you really don't know whenever someone else is is playing your
game so here now i can press play if i fall down i'll start here usually this part should be
an introductory part where uh you can fall and here you should enter some some place
so if you die here for example in this jump i really don't want it to go back to the
start so i will put a little checkpoint here and it should be really really
visible so the player doesn't skip it so you will see this immediately
oh what's this seems to be light up and whenever the character falls then
you should be able to respond here now these parts also should be very
easy except this one could be a little rage inducing yeah it's it's really tricky
actually so i'm gonna also put a checkpoint here here you if you fall through this gap
it's fine you you can go here and maybe because this will be a second part where i only can access after i get this blue key
and i go back through this path and then and then go through the gate and
here probably we already took this this checkpoint and it's really not that
difficult and it should add a little bit of tension if you fall here and go back here
then it's like oh i really need to get my jumps on point so i believe it is fine like
this the pickups well the coins i will add after the set dressing of this map i will add
some props and make it look a little bit better for but because right now everything is gray
so let's start with that this part will also be sped up because what i'm gonna do now is
just replace most of the geometry if not all by the assets that we're gonna use that
we have imported from the other project here you see me scaling stuff up and down it will
be probably better if i get rid of the snapping in the rotation and in the scale so
i get a more natural scale scale so that's pretty much what i'm doing right now and regarding the scale usually it won't pixelate
too much or it won't be that noticeable if you use a 1.75 scale so maybe with 2x scale it can be
noticeable but it really depends on the assets depends on how realistic it look
looks the texture in this case it's a very cartoony type of feel so
it's a little bit harder to notice also here i'm adding some rotation so
those surfaces are not looking too plain because a simple surface that constantly repeats
itself and it's in the it's parallel to the to the ground sooner or later it will get
boring and i'm not gonna worry that much right now by leaving those blank space because
later on i will probably do another pass with more props to hide anything that
will look kind of weird or not believable also in some part of this video i
will select the geometry here in that that we created with the modeling tools and
remove the collisions and also make it hidden put it in a folder so i can hide it and find it
really easily and also set the value of set actor here in game to true that way i can press play and
i won't be able to see it and i won't need to just delete that geometry because maybe later i could
i can review what what i need from that geometry and in this part it happens i'm showing
something that happens very frequent you're putting the props and they don't exactly
align with the with the scale that you have proposed for your game or with the height
in in my case those stairs were too high and it made me have to elevate
everything by a little bit here i'm just testing that the jumps are still doable
and after that after positioning in the quote-unquote correct place i can now move it
around and position it to the new height that way i know that those jams are still doable and i'm
still keeping the distance that i planned before so yeah here i also need to add some collisions
to some props and this will be very noticeable when you start play testing you will see that
i'm putting assets in this case this stair had an angle that it was too steep so i
just went inside the character to fix that you can find that value in the character
movement component and it should be should be something like angle to walk on and i
just bump it up to 70 i believe so play testing like i was saying very important will let me see
this kind of errors before i just think i'm done with the with the map because if you don't catch
these errors then you will show it to someone else they will get stuck and you will feel defeated
i mean it's still a learning experience to have someone play test your level but you want to catch
most of the errors with yourself play testing it so that's why it's important and you don't
really need to play test from the start here in well in most of the times i'm play
testing i'm just right clicking in the map and clicking in play from here so i don't need
to go to the start of the level and to reach that part that the specific part that i'm testing right
now i determined that it was too easy maybe and i started moving around the the platforms and here
these jumps they were especially somewhat annoying not too not that much so it was something that
i wanted to maintain so i'm using those cubes to try to get the same scale the same
distance that this part offered you will see that right now i'm following the
geometry exactly oh well almost exactly as it is but i will take some liberties some freedoms
in the positions and rotations later on or i do believe that is at the end of this sped
up video that i'll start rotating some stuff but this first pass of assets let me know that
this is still working as well as my prototype as my blockout and here i'm rotating it and even
though though i have been changing it by other assets at least the floors the platforms
are still working after having the floors changed by the meshes that that we're gonna
use then we can do a second pass of props where we can add all the stuff that will make
it look a lot better in this case some foliage won't do us any harm and we can tweak a little bit if it is not working for example
if the plant is under empty space then we can move it or we can delete it
then we are using some props also from the from the marketplace from that free asset to make a little a little foundation for
our i don't know how to call it maybe house or whatever it is where the goal is right and
we're just trying to make everything first look similar and then start adding some details
for example that wall with with the window and using the same assets that that i use for
the platforms we can just rotate them scale them and position them in a way so they look like
rocks so it's really not necessary to create that much assets with and i would have prefer if
it was a complete rock so that would have made my job a lot easier but just by rotating it and
putting it together with other other platforms i can make it seem like it's a bigger construction
that what really is so by using the parts now i'm trying to make the go location a little
bit more noticeable i mean if something has a gold a gold border then should be really important
right and i'm adding a roof just in case you can jump from another platform to that to that
area so that way i'm making sure that this area can be only accessible if i get the red key
also i'm playing a little bit with the lightning and that lighting inside that room should
reflect that it should is an important route or something like that also i'm adding some
some meshes in the bottom of floating platforms just to make it look a little bit more
believable that is not just a floating floating floor the next part is
trying to make sense of the other gate and later on i will run into a problem where
i can cheat and skip that gate but it all comes down to play testing you will still see
even though this this video is sped up like 800 percent so hopefully it is noticeable but it
is it took me a long time i mean i'm not really an environment artist or a level designer
i i know some principles of level design what to take in consideration but because
it's not something that i do often it is taking me a little bit of time took me like
an hour and two minutes but it was really fun so i really didn't notice that i'm passing here
i'm trying to create some crystal structures using only one prop and rotating them
grouping them and then duplicating them and later on i will try to add more more of that
those crystals designs to more parts of the map here again i'm trying to get rid of just floating
platforms voting boxes that's okay i believe but just uh almost a plane she didn't really
look that good to me here i'm trying to avoid the player skipping the gate because you
could you could jump through that hole and you really didn't need the blue
key also you could jump to the side and that was also an issue so i try to to
fix it by just blocking that that part and some some parts that just really
a little bit of touching and care so here we have beam up it's looking a lot better i mean i did my my best so yeah it was pretty fun took a long time but at
least we have the map there are a little details right that we can add oh or well that i should
add for example here i know this diet i had some where is my static mesh some clouds and
these clouds are very big so i can put them in the base something like this and also the cloud b should help me a lot and this cloud if i scale it maybe by 10 will allow me to kind of give the idea that i'm really up up there in the sky so this
one i'll scale it by eight and again put it someplace like this and i'm
gonna get rid of my snapping tool i'm going to move them around a little bit something like that maybe a little bit lower or to the side and i can even rotate rotate it to make
it look like it's completely another asset this one is looking very similar so i'm
gonna rotate it also maybe to the side and then would put it someplace like this move this one around and let's press play and see how it's looking um it's a little bit better i should also use these
clouds and put it in the sky like so maybe one of these ones here also where's the other the cloud d and this one shouldn't cast shadows
otherwise it will look a little bit weird so i'm gonna select them go to lighting
cast shadow don't let them cast shadows and again i'm just winging
it i don't really usually do environment art or nothing of the sort but
you see that the tools give me a lot of a lot of room to a room to play with it
then yeah and the harder i try to talk while doing something the harder it gets
let's press play we have some clouds there i mean it's supposed to to
be a little bit cartoonish but this is maybe too close and i also had some effects there
was a wind system which is a a blueprint that i can modify the curve for
example like this and create another node and it will give like a wind
moving around there it is and this type of blueprints are very
useful because it can help guide oops the the way and this is not what i wanted to
do so i'll again search for the wind system here for example let's put these like that and i'm gonna move it a little bit and then see what's happening with that so it
takes a little bit to appear but there it is and i really should extend that
cloud that's that sea of clouds oh and i get some nice reflections out of this pretty cool also another thing
that can help us a lot for example let's just select all these clouds and maybe group them with ctrl
g duplicate them rotate them make sure that you don't see that they're
actually the same assets something like this something like that and let me press play and see see how it's looking play now it does see it does look
like a like a sea of clouds and i have clouds there and there and there and the last thing we need to do is test
the is the level see if everything is doable everything is possible i hate this part i really hate that part yeah i can do it i can do it it's so tricky that jump you don't
even know dude i can't be that bad usually with those type of jumps better to do it from the side yeah like that finally got the blue key this is a simple
cheat i just die and i returned there on this checkpoint let's see if this working
probably that needs a sound i forgot completely about that so i mean it's good because
the punish the punishment is not that bad we got the red key we probably can skip most
of the way back going here then here it is be a lot better if if my character faced to the other side but that could be something
that you guys can add in your project so everything's working correctly something that i forgot to add before wrapping
up the video was some particle effects here there should be something called
pollen and i'm gonna drag and drop it here and it gives me these types of
particle effects of things flying to make everything a little bit more magical and
i'm gonna drag and drop one duplicate it here just so i have this kind of
effect everywhere in my map yeah that's looking a lot better and now that the map is finished also it's good to label everything we've
done for example everything with bp and an underscore should be except these ones
gameplay elements we can create a folder call it how do i rename it there it is gameplay then with this in mind i can go through for
example these wind systems should be vfx the pollen also no how is it cold than this these two assets new folder no not new folder excuse me let me delete the new folder or did i delete everything here win system bfx what's this name bfx pulling magic
camera let's search for that bfx what why can i find them should be around here well for some reason is not showing up while the lights i can add to a folder called lighting and most of the the meshes will be the level
you can leave it like this or you can also send everything there and separate it maybe with
level environment obstacles etc but it's a good a good habit to organize your outliner this
player start should also be in gameplay some lights here skylight let's move in to light
but it's a good idea because if you go back to this level in maybe some weeks or after months
it is a good idea to to have it categorized and in a easy way to find any asset that you may
need so when i press play i should have those those little dots and i don't know what happened
to the other one so i'm gonna duplicate this one probably it got deleted without me knowing but now i see it be sure to save and after saving be sure to check
it out now it's looking a lot better got my clouds that one looks a little a little
bit weird but i'm not gonna get too picky about it one thing i did forget to add was my
coins usually the coins will guide the player so let's just add them really
really quickly where's my pickups coins should the first one should be here the
second should be here if you don't want the player to skip this part you can just
duplicate them here i'm gonna put another one in the top so they know they should be able
to reach them i'm gonna put three coins here i'm gonna put a coin here so this will probably be a point where
they are very likely to fall down i could put like some x here coins and last but not least some coins leading to that here i'm
gonna put a coin in each one of these platforms so if they want all the coins
they will need to jump on each of these platforms and this one really doesn't
need a coin because we have a key here again a coin here maybe a bunch of coins here and now whenever we play we will have these coins they are a little bit static i don't
like that makes make it seem so i don't know boring so i'm gonna make
them rotate i'm gonna open the coin gonna go to the base pickup and
here i'm gonna add rotating movement compile this will make all my pickups rotate even the keys the key i really don't
want it to rotate so rotating movement i'm gonna uncheck this how to activate compile it and
in the coin i'm gonna check the auto activate so only the coins and i'm gonna simulate
only the coins will be moving like that and the keys will stay static if you want
to create a hovering movement you can also we can also do that through components
here there should be an inter to movement again i don't want this movement to auto
activate first but let's check how it is moving i don't want it to be a one shot ping
pong should be fine teleport type is fine sweep check if still in world i need to define
this control point so i'm just gonna put the first one at zero zero and the second one
maybe minus 40 the duration will be 0.7 compile save it and we will see now what
happens with this and it's really not a smooth a smooth movement but for me it works you want a
smoother movement then you can this control point made it to instead add another one minus minus 30 and here our end goal was minus
40. that should smooth things up a little bit just a little also this one i should disable that how to
activate and it was still a bit stiff so let me put -5 3 5 here it save it compile it and
the coin i don't want it to move i only want that key to move up and down so here in the
key i will activate that interp to movement compile it save it and now i can see
the key moving around as expected so if i do play the game i will see
something moving there up and down which should really call my attention i see
the gate the red gate a key and now i can start getting those coins and the rotation is too much
for me let's change the rotating movement to maybe a third of it let's see if that's working
for us yeah and that's pretty good let's keep it like that to recap this tutorial
we have seen blueprint fundamentals also gameplay development and a little bit of
level design we have created a game from scratch we have also added gameplay mechanics using
blueprints and created a level that can be played and shared with your friends the next steps
for this is that you can use this knowledge to be able to design more levels and create your
own gameplay mechanics so the game becomes more unique and also it will open the door to the
exploration of all the features inside the engine if you reach the end of this tutorial be sure
to check the comments to find a coupon code for one of our premium courses only available for
the first 100 people also if you liked what you saw and want to support our work while leveling
up your game dev skills make sure to check our recommended resources where you can find plenty
of tutorials made by industry professionals