Transcripts
1. 1.01 Introduction: In this course we're going
to learn how to make it to the Idle Clicker
game using blueprints in Honorable Engine five by
recreating a game similar to Clicker heroes and
Cookie Clicker A. This course contains everything you need to know to
get started with two D idle clicker
game development in Honorable engine five, including how to create
tile sets and tile maps. How to add static as well
as animated two D assets. How to spawn damage and kill enemies using
the mouse Cursor. How to create an item shop
with spawnable items. How to create an auto click
mechanic to automatically deal damage as you purchase
items from the item shop. How to add multiple
levels to the game, which you can switch between. How to display
floating combat text, how to create two DUI
and world spawn UI. How to create UI tool tips. And finally, how to add
the ascension mechanic for replayability to
deal more damage as you ascend during the game. I'll also provide to you the
finished project so that you can inspect it as you wish while following the course. At the end of this
course, you'll be able to confidently create your own two D clicker game from scratch using
Real Engine Five. I hope you'll join me
in this course today. And remember that I'm
always here to support you throughout the course
and I hope to see you soon.
2. 1.02 Downloading Unreal Engine 5: To install Unreal Engine five, you first have to go
to epic games.com. So go over there,
and you'll find a blue download button
to the top right. Go ahead and press on
the download button. And here you will get the installer for the
Epic Games launcher. So go ahead and
run the installer. And once you have installed the Epic Games slauncher,
go ahead and log in. So I'm just going to type
my e mail and my password, and I will log in
to the launcher. Once you have signed
in into the launcher, this is what it will look like. So go ahead and press on
the Unreal engine tab. And inside of this tab, you will probably be
on the new section. Go ahead and click on Library. And inside of library, you can see all of the real engine versions that
you have currently. But if you're new here, you probably have nothing here, and you might see a gray box where you can
download real engine. And if you don't see it, you can always click on
the plus up here, and it will give you this
gray box and you can click on the number to select which version of Unreal
engine you want to install. Now, I am going to use the
latest one Unreal Engine 5.3. But if you're watching
this course in the future, if you have 5.4 or
5.35 or whatever, you can still
follow this course. There isn't a big change. So let's go ahead and jump
into Unreal Engine 5.3. I'm going to go
ahead and update, and I will launch the engine.
3. 1.03 Creating a New Project: When you launch Unreal Engine, this window will pop up for you so you can see your
recent projects, and you can also see
some other tabs. This tab will be empty if you don't have any
projects previously, but you can open them here
if you are working on a project Right now we
wish to make a game. So I'm going to go
over to the Games tab. But as you can see
in Unreal Engine, it's not only about games. You can also, for example, automotive architecture
and so on. Let's go over to the
Games tab for now. And inside of the game tab, you see a lot of templates
that you can start from. For example, if you want to
make a first person shooter, you can choose the
first person template. If you want to make a top
down game like Diablo, for example, you can
start with this template. However, I'd like to start
with a blank project. As you know, if you have
taken my previous courses, because I want to teach you
everything from scratch. Now, all of these templates, they can be created
from a blank project. And they are not difficult to create if you know
what you're doing. We like to start from a blank project and build
everything ourself. I don't really like to start
with the template. Let's with a blank project, teach you everything
here to the right, Select Blueprint as the
programming language for the target platform.
It is desktop. For now, we can always focus
on mobile another time. But this course
is about desktop. I will probably do a course
in the future about mobile. But even if you select desktop, you can still make
it for mobile, later on, you can make it
both for PC and mobile. Let's select the quality preset as maximum for the data content. If you have this
ticked on, just go ahead and tick it off so
we don't have anything. Again, I'd like to start with a blank project without
anything down here. You can select where you
want to save the project and then you can give
the project the name. Now I'm going to call
this one Gin Clicker. And you can always call it whatever you want, it
doesn't really matter. And go ahead and
click on Create. Once you launch on
real engine five, this is what it will look like. Now I am recording in four K resolution and I
have a four K monitor. The UI might look a bit
small to you when I'm recording this video
for this whole course. I'm actually going to upscale my UI so you can
see what I'm doing. If you wish to know how
I can do that as well, you can click on Tools
and go to Debug. Go to Widget Reflector
inside of here. I'm just going to increase
the scale of my UI. Maybe not 21.3
maybe this is one. This 1.3 I think I'll
keep it at 1.3 and I can always change it in the later lessons if I think
it's too large or too small. Let's actually keep it at 1.25
and I'm going to close it. Okay, so in the next lesson, we are going to take
a quick overview of Unreal Engine Five, so we can get confident with
it before we build our game. Now if you've already taken my previous courses and you already know
Unreal Engine five, you can skip the next lesson. But let's go over to the
next lesson and get started.
4. 1.04 Unreal Engine 5 Overview: All right, so before
we start our game, we are going to take
a quick overview of Unreal Engine Five. Now if you've already used the engine before and if you've taken my
previous courses, just go ahead and skip this
lesson to the next one. Now here in the middle of
the engine is the viewport. Inside of the viewport
is the world. This is your game that
you can see visually. As you can see here we
have landscapes and so on. But if you right click
inside the viewport, you can see you can control your view holding right
click on your mouse. Now if you hold the right
click and click on as well, you can see you can
move holding right click on the mouse and
clicking on W, you can move. Now you can see I'm moving very slowly because this
is a large world. If you want to move faster, just click up here
on the camera speed, I'm going to increase the
speed to something like 16. Instead, if I hold the right click on my mouse and
click on W. Now you can see I can move a lot faster in my world,
as you can see here. Okay, You can also click
on D to move to the right, click on A to move to the left, and click on to move back. But remember you have to hold the right mouse button and
then click on W, D and A. This is actually how I navigate around, usually honual engine, I just hold the right
mouse button and I just know travel around in the world and see what I'm
doing developing the game. And of course if you
want to zoom in and out, you can zoom in with your
mouse wheel, just like this. And you can zoom out as
well with your mouse wheel. And you can just fly
around in the world, try to get confident
with the movement. Now, if you're used to playing first person
shooters and so on, this is natural for you. If you haven't played that, just try to run around and see if you can get
the grasp of it. All right, so we have a couple of buttons up here
in the viewport, we can click on this one. And here you can, for example, show your FPS frames per second. And when you click that, you can see it appears
here to the right. Now, it doesn't really matter, for now, you can change the
field of view and so on. But the good thing about Unreal Engine is
you don't have to know what every
single button does. I don't know, maybe
half of the buttons, because I don't do cinematics. Usually, I don't do
movie cinematics. For example, automotive,
I don't design cars. There are a couple
of buttons that you actually don't need when
you're developing your game. Try not to remember everything, but try only to remember what is really
necessary right now. What is really necessary right
now here is the game view. With the game view, you hide the icons inside of the level. So for example, if I click
con G, this is the game view. See I hide this
orange selection. Now if I click on, again, on my keyboard, I
disable the game view. As you can see
here, The shortcut is when I click
on the game view, you remove all of the icons. Now if I just add a
light, for example, a point light, and here I have
an icon of a point light. Now you don't really need to
add a point light right now. I'm just showing you
if you click on now, it hides the icon for the point light.
And I can't see it. If I click on again, it shows the icon
for the point light. The point line is a
bit small right now. If I click on it here you can see it's
actually down here. It's a big world. It usually
disappears, but here it is. And if I click a G, and G again, it appears the game
view is really, really good to visualize your game without
any of those icons. If I build a world, and you can imagine you
have a lot of icons, if you have a lot of lighting, you have a lot of objects
inside of your level. You can click on G to
remove all of those icons, and you can see your world
without any of those icons. Now the next thing is
the immersive mode. If you click on 11, you maximize the
viewport and you can visualize your world
in maximum view. This is really, really nice if you want to see what
your game looks like. Now again, you can click
on G to show icons, G to hide icons. Click on 11 to minimize it. Again, two important buttons, the immersive mode
and the game view. Now over here we have the
perspective view and we also have other views,
the orthographic views. Now the most important
one is the right view. This is what we will be using because we are
going to work with two D. We aren't really going to go inside
of a three D world. We don't need the
perspective too much. But for now, let's go
to the right view, and this is called the
orthographic view. If you zoom out with
your mouse wheel, you can see this is
actually the world, the open world in
the right view. Looking into a two D view, you can see it from the top. What it looks like,
obviously can't see much because you can't see
the hills from the top. If you see it from the bottom, this is what it looks
like, can't see much. If you look at it from the left, this is what it looks
like. And so on. You can see the different
views of the world. This is of course, the
perspective view back again. Here we have different
lighting modes. We don't really
need them because we are not going to
work in three D. Don't really focus about
this right now in the show. You can show and hide
different things. We will be using it later. For example, you can
show the collision, you can hide the fog and so on. Not really necessary right now, let's not get into it now. Very important are those tools. Over here we have
the selection tool and this basically selects
items in your world. Now in order to use those, let's actually add
something into the world. Let's go to this tap quickly
Add to Project button. Very important
here. You can add, for example, a basic shape. Let's add a cube. Here's the cube we have added. I'm going to decrease
the camera speed. We are moving very quickly in the world,
putting it back to one. If you click on this one, you can see this is
the Select tool. And remember you have shortcuts
for these tools, you can. This one is, the next
one is the move tool, you click on it, you can see
those pivot points appear. Now if you click on the red one, you can move to this axis. You click on the blue one, you can move up and down. If you click on the green
axis, you can move this way. Now the colors for these
are actually X, Y, and Z. And you can see it here
in the details panel. You can see the
location of it, the X. If you hold the mouse over it, you can also see
the value actually before it usually told you
that this is the X axis. But I can see now it's
not doing it anymore. But basically, the
red is the x axis, the green one is the y axis, blue one is the z axis, the x axis, y axis, and the z axis. Okay? You can move it like this. You can also hold it here in
the square in the middle. You can move it at two
directions at once. Or you can hold it over this white small
sphere in the middle and you can move it at all
three directions at once. You can also here in
the details panel, maybe you have noticed this is the details or whatever
you select inside of here. If I select this here, those ground planes
from this open world, or if I select my cube, see different details about the item you have
selected in your world. For example, I can see
the location of my item, I can see the rotation of it. I can see the static mesh which is basically
the three D model. I can see the material supplied. I can also see things
about the physics. And I can see, for example, simulate physics is not applied. I can see the
gravity is applied, I can see collision options, lighting options,
and so on and so on. And you can see you have a
lot of things you can see. Don't worry about it for now. We are going to work a
lot in the details panel. It will get easier
and easier for you. Much of these things we're not going to use because we are, again working in two D, so don't worry about this, but basically here
for the location, you can either move it like this and you can
also do that in tod, or you can move it like this if you just click here and
drag with your mouse, click and drag with your
mouse on the numbers. And you can move it like
this. Or if you have specific locations,
you can type it in. If you click on
it here and I can write 1,450 for example. And I can click on Inter. You can see my cube moves to the precise location.
You can do it like this. You can move it
manually, move it here. Or you can type
the number again. Now the rotation, which is the next one if you click
on, on your keyboard. So the first one was, the next
one was for the move tool. The rotation tool is E on the keyboard with the rotation
tool, self explanatory, you can rotate the item
in different axis, Again, in two D, we
only have two axis. Don't worry about the third one, but it's still the same process. So I'm going to teach
it to you this way. Again, for the rotation. You can also change it over here. If you want to
reset the rotation, maybe you're not
satisfied with it. You can click on
this small arrow and it will reset
everything to default. So this is the rotation tool. The last thing is
the scale tool. If you click on R
on the keyboard, you click on Q for
the select tool, for the move tool, for
the rotation tool, and R for the scale tool. Now again, for the scale tool, you can scale it in
different directions. Or if I click on
control Z to go back, you can also scale it uniformly
in all three directions. If you click here in the middle, just like this again, if you're not satisfied, you can always click
on this arrow. You can also scale
it again if you just click with your
mouse and drag. Or if you want to
scale it uniformly, you can click on this lock. Whenever you scale, one of them, all of them will scale as well. This is the good
thing about the lock. If you want to scale
only one of them, you can open the lock and
you can just scale on one side at a time,
okay? Very important. Remember those. We are going to use them throughout
the whole course, the next courses, and probably every single
course we make. Just remember the Q
for the move tool, for the rotation tool,
and R for the scale tool. We also have some
snapping options here. As you can see, when
I move something, it snaps to a grid. It's not moving smoothly
because of this. You can click here and
increase the number. This will snap even
more than before. This is nice if you're trying to build something
with a structure. Now you can copy paste this. If you hold Alt on your keyboard
and you click and drag, that will copy this item. I'll try to copy it again. Hold, click and drag. You're holding Alt and you
can see I copied it again. Now the snapping is really, really good if you're trying to build something like
this with a structure. Now if you don't
want the snapping, you can always click on this button and this
will disable it. You can, you can
move it smoothly. You can do the same
thing with the scaling, the rotation and the scaling. You can increase the rotation, snapping and also
the scaling can disable the scaling snapping or increase the snapping of it. I'm going to put it on again
and just go back to ten, which is the default as before. You can turn down and up
for the camera speed. Now the good thing about this is if you're focusing
on small objects, you want the camera
speed maybe to be lower, so you can move slower and
focus on what you're doing. If you're moving in a
really large world, you can see I can move a lot faster by increasing
my camera speed. This is how we usually use it. I just go back to one here. Okay. The last very
important thing up here is also the settings. You can go to the
engine scalability. And right now you
can see I'm running the engine at epic quality. You can also set
it at low quality. For example, if you're lagging, if you have a low end computer, you can see now my engine is not really using
a lot of memory. If you have a good
computer, for example, you can always increase
the scalability. I usually run cinematic
if I do something like architecture or if I do
a cut scene in a game. It's really nice to run
cinematic and it's going to lag. So right now I'm
not going to do it because I'm also
recording the course. I'm just running it at
Epic for now. All right. So let's take a look at up here, you have the file Basic buttons. As you know from every software, you can save the game
or save the level. You can also create a new
level which we will do later. You can export
everything and so on. You also you have the editor preferences and inside of the editor references, you can edit things
about this editor. For example, this
selection is orange. Maybe I want it to be
something like red instead. I can do that O, you can edit things about this. Now I'm just going to click on control Z because I'm
satisfied with the color. But basically you can
change things about this editor in the
project settings, you can edit things
about this project. For example, you can
give the project a name, your company name. Later on, maybe you
release the game. People can see your
support contact e mail and they can contact
you if there are bugs. You can also add movies. For example, when
you open a game, there is a small movie about the logo for 5 seconds
and then the game starts. You can add movies
here, start up movies, you can package the game
to different consoles. You have a lot of things that
you can do inside of here. Now we are going to go inside
of here because you have some things that you can work with here and we
will do so as well. So we can see you have a lot of that you can do in
the project settings. Again, just like I
told you before, do not focus on all of them. You're going to use even 20% or you're going
to use 20% of them, Maybe 15% 10% Don't
really focus about this, it'll be too confusing
if you start doing things you're not
really going to use later. For now, let's not focus
about the project settings, Let's just close it down. We are going to go through
this whenever we need it, but basically most of these things you're
actually not going to need. Let's focus about all of this. We are going to go through
this course and I'm going to teach you every single thing
that you need to know. Over here to the right, you can see the Outliner. If you click on the
objects in the world, you can see they are also
in the World Outliner. The World Outliner is basically just showing what items you have
inside of the world. You have the three
cubes we just added. We have some lighting
that you can see here. We have a sky and we have
the light, and so on. These are actually here and you can actually
see them here. You can click on the
directional light, for example, this
is the sun light. If you click on,
on your keyboard, this will take you wherever
you have selected. If I click on, it will
take you over here. Now if I click on,
because I hid my icons, to press G. So you can see the icons and here you can actually see all of the lights. They're hiding it over here. Again, click on if you
want to go there quickly. So for example, I can
click on the cube. If I can actually find the cube, I can't find the cube. The good thing about the
outliner is that you can find the cube here and
you can click on the cube. You can actually see
the cubes over here. You can select
items here as well. Click on on the keyboard to take you there if you wish
to go there quickly. On basically the
World Outliner is showing you what you have
inside of this world, inside of your game right now. All of these are just the
landscape parts here. As you can see, there's not really much
into the outliner. You can create folders if
you want to stay organized. Clicking on this folder icon
will create a new folder. You can just rename the
folder here that we created. You can rename it and you
can add things to it. If you click and drag
the item into it, you can stay organized this way. You can hide items
by clicking on this and you can click on it
again to show them again. Yeah, that's basically the outliner we
already talked about, the details panel,
and over here, not much to do. The most important thing
for now is you can add things into the world by
clicking up here, for example. You can add lights. We don't really need that. We are going to work with two D. You can add shapes again,
we don't need that. We are going to work with two D. We're not really going to
focus on this too much, but basically we can add
things like volumes. We are going to add it later. So we need something inside of here very, very
important button. You can also play the game, and you can see what
the game is like. Now, we don't
really have much in the game, not really
much happening. I'm going to click on Escape on my keyboard and we are
going to get out of here. All right, before we end this, the final thing inside of this engine is
the content drawer. If you click on it, this
window will pop up. What the content drawer is, is basically where you can
add all of your game files. If you have the two D art that you have made
in your software, for example, the characters,
the environment, the tile sets, all of those
files will be inside of here. The music, the sound
effects, whatever you have. If you're making a three D game, you have the three D
models, textures and so on. So all of the files
will be inside of here. And you can click and drag
things into the world, and we can use them inside
of the content drawer. I don't really like to have
the content drawer like this, because if I click
on something in my world, it will minimize it. Again, I think it will
also be confusing for you. While you're
following the course, what you can do is click
on the content drawer. And I'm going to click
on Duck in Layout. And this will make it so the content drawer now
called the content browser. It will stay here in the
viewport or in my view, and I can just resize
it if you want. You can resize all of
the panels if you want. It's a lot better
when you follow this course that you can
see this all the time. And I usually have it
up like this as well. It was like this in
hole engine four. Yeah. So basically you
can see your files, you can make new folders. If you write, click on
this content folder, for example, you can
click on new folder. You can call it, let's say assets or whatever
you want to add. Later on, you can
even right click on this folder and you
can go to Set Color. You can give this folder
a color if you want to. Just like this, you
can stay organized. Whatever you want to do, you can always right click again, clear the color if
you don't want it. Now all of the files
again will be here. You can also click
on the Add button and you can add a new
folder if you want to. You can also see, you can add other things like
the Blueprint class, this is the programming
we will be doing. You can add a new level, you can add a material. You can add a lot
of things about animation foliage if you're doing grass and trees and so on. You can add something
about the paper to T, which is the to actually the pix a lot we will
be working with. We will be adding all of those. We will learn every
single thing here. You can add physics and so on. You can also do it, instead
of doing it from here, which I never use, you can click on the folder and you can
write click inside of here. And you can add the same
things I usually just write. Click here and add things. But you can also do it up here, okay? This was everything. Now if you want to minimize or make these icon
smaller and larger, you can hold control on your keyboard and
you can zoom out. This will increase or
decrease the icon size. You can also hold
control and zoom in to increase the
size of the icons. Now you can also click on
Settings, I nailed Size. And this is basically the same thing that was it for Nal Engine five
and the overview. I hope you're a
bit more confident in what is inside of here. Again, we are going to make a whole course inside of here, so you are going to get
confident with it for now. Let's just jump over
to the next lesson.
5. 2.01 Game Introduction: Hello and welcome. And thank you so much for
joining me in this course here. This is just an introduction
to the game we are creating. I'd like to show you what we are creating before we get started, so you have an idea of what we are doing
inside of this course. So basically, we are
creating a two clicker game. And here it is, inside
of Unreal Engine Five. And we're only
using blueprints to create this project,
so no C plus. Now I just want to show
you what the project is. If I just click play here, you can see the music
is already playing. This is basically a
clicker game like Cookie Clicker or
Clicker Heroes, if I just disable the music. So I can speak freely
if I click here. So the volume 20 and
click play again. Basically this is
like Clicker Heroes, where you have an
enemy in the middle. You have shop items here to the side, you
have coins up here. I've just given myself
a lot of coins so I can buy all of this and I
can show you the game. I also have some levels
here to the side. And I have a timer that I have
to kill the enemy before. Because if I don't
kill the enemy, timer will reset and the
enemy will heal to full. Once again, I have to kill this enemy before
this timer runs out. If I kill the enemy, you can
see a new level has been unlocked and I can go to the next level to
spawn the next enemy, and I can kill this enemy. Now every time I kill an enemy, I gain coins and I can go
further into the levels, and the levels continue
as soon as I have money, I can now unlock items
which I can buy from here. For example, you
can see my mouse is doing 15 damage per click. I can also see it here, if I hold the mouse over it, it says currently doing
15 damage per click. And I can click on
it and buy one. And now I do 40 damage per click and I can
click on the enemy. And now I can see
I do more damage. These items down here are
auto clicker mechanics. Basically, if I buy this one, it says it gives me
five damage per second. Five by one. Now you can
see it automatically deals damage to the enemy and it
deals five damage per second. Obviously, this is not
going to kill the enemy, and the enemy keeps
restarting the health. But if I buy something stronger, you can see it can reach
the death here and unlock. Now I have made this
super easy for now, because I just want to show
you what the game is like. But obviously the health
needs to be a lot more and the cost needs
to be a lot more as well. Now in the blueprints, if
I just remove my coins, if I go to the player, I click on the amount of
coins and set it to zero. And if I click on Play, you can see here for items
I can't purchase yet. The buttons have been
disabled and the button changes color as well as
soon as I have money. You can see now I
can buy this item. And as soon as I buy one, so now I have 15 coins, I can buy one and I spend
the coins here to the side. You can see how many I have
bought as soon as I buy. All you can see, by the way, every time you buy an item, pons here to the world. So if you buy an
item, it spawns here. And if I buy more of it, you can see it keeps
spawning here. So all of the items you buy will spawn into
the world as well. As soon as I have bought all of the items and a specific amount, there will be an ascent
button that will appear. When I click on it, I can
ascend to the next stage. This is basically
the game we are creating and there are
also bus mechanics here, so bus enemies that will
appear later in the stages. This is basically the clicker
game we are creating. I hope you'll join me
in the next lessons. It will be a lot of fun to
create all of this with you, and I promise that
it will be easy, and I'll make it easy
for you as well. Let's continue.
6. 2.02 Creating a New Level: All right, let's get
started with the project. Let's go ahead and
create a new map inside of the folders in the content browser.
I'm going to write. Click first and create a new
folder and call it maps. Just stay organized
with the project. Now inside of here I'm
going to click now. You can create a level
with two methods. You can either right click
here and create a new level. Or you can go over to File and you can click on New Level. Now the difference is
if you click here from here and you click
on New Level here, you can see that you can make an open world
level. You can make empty open world
level and so on. So you have some
templates down here. If you right click
and click on level, you don't get those options, you just automatically
get an empty level. I just want to make an
empty level because again, we are going to create
everything ourselves. Right click here,
make a new level. Let's call this one map. I usually call it map, let's call this one dungeon. I don't think we will
have multiple maps, This is the only
one we will have. Let's just double
click this one. I was going to tell you, do you want to save this map? This is actually what
it means when you have stars at your icons. If you have small
stars, it means you have not saved those yet. Let's just go ahead and
click on Save Selected. And now we are
inside of this map. Now you can see it's very
dark, we can't see anything. And also here in the Outliner, you can see you
can't see any items. This is because your
level is empty. You don't have
anything, you don't have lighting, nothing. We are going to add a
lot of things here, but for now we just wanted
to create a new map. Let's go ahead and
click on File Save All. Very nice key to press often because sometimes
the engine crashes. But let's go ahead
and save everything and let's move on
to the next lesson.
7. 2.03 Importing the Environment Assets: Let's now go ahead and import
the environment assets. Now I have included this
for you with the course. We have some course materials
that you can download. Now, inside of these
materials, again, I'm going to add more items
as I develop this course. Sometimes if I go to
the sound effects, you might see a lot
more sound effects when I'm inside of here. So you can see I have those, but in your folder you might have a lot
more sound effects. Again, I'm going to
add more and more to my course materials as
I develop this course. Don't get confused if I
don't have this many, this many items inside of here. All right, for the environment, let's go to the
environment here, and let's take those two. So I have the dungeon
prison environments. Now if I can double
click on it and zoom in, this is what it looks like. The same thing here
for the props. I have some props I can use. Now let's close it down
and let's import those. To import it, let's
make a new folder. I'm going to right click
here, make a new folder. I'm going to call it
assets inside of here, I'm going to right click and
make a new folder again. And let's call this
one environment. Okay, I'm going to
make my icons a bit smaller because they're
taking a lot of space. So I'm going to click on Control and zoom out with
my mouse wheel. Okay, now I'm going to enter
the environment folder. And it's out of here. We
can now click and drag. Let me just open
the folder again. I can click and drag them
into here. There we go. Now remember, if you can't
click and drag them, you get this icon here and it tells you you can't really drag
them into here. This is because
maybe your folder is a Ip folder or a raw folder. Remember to right click your folder and
extract the content. If it's a Ip folder, it needs to be a normal folder. Extract the content.
After you extract, you can import stuff
inside of here. Now when you import
things inside of here, you can click on it and you
can actually see it's blurry. It's not really picks a lot
and see it's very blurry. And we don't want that. This is because real engine
is a three D engine. It blurs things which
looks nice in three D, but it doesn't look
good in two D. A simple thing to do is just select both of them and you can just
click on Control and click on the next one
that will both the right click go to Sprite actions and click Apply Paper
two D Texture settings. This will make sure that items inside of here
are not blurred And it is actually pick a
lot as you can see here, now it is pick a lot, everything is looking good. Let's go ahead and
click on File and save everything, the textures. Now I'm actually going to make a new folder called Textures, and let's just import it. Inside of here we have
the Assets folder. Inside of it we have
the environment, and inside of it we have
the Textures folder. This is because when we create a tile map and a
tile set later on, I'm just going to
place them out here. These we don't
really need anymore. Later on, I'm just going to have them inside of
the Textures folder. But for now, this was it. Let's move on to
the next lesson.
8. 2.04 Creating a Tile Set: Now that we have
imported the assets, we can now create a tile
map and a tile set. Now to know the
difference, you can write click here and go into paper to, you can see there's
something called a tile map. There's something
called a tile set. Now the difference between
them is that the tile set, there are the tiles we need
to paint our map with. The tile map is the map itself. You can imagine it
if you're a painter. You have the pellet, which is the tile set which is our tiles, and the canvas which
is the tile map where we paint our map itself. Let's go ahead and
create a tile set. I'm not going to
create it from here, but we can create it
by right clicking on the dungeon prism. You can see this
is the environment we imported or
basically the tiles. Let's right click
this one and go to sprite actions and
create a tile set. From this texture, you
can see it's created. I'm just going to
double click here. And you can also, by the way, click on it and click
two on the keyboard. That's easier sometimes. I'm just going to say S
as a prefix for tile set. I'm going to double click
it and open it up here. You can hold the right
click and you can pen around and you can zoom
in and out and see the tiles. Click on them to select them.
That's what we're doing. Later on we're going
to select the tiles and then paint them
inside of the tile map. Now we can see here, if I select a tile, it's not really fitting. It's selecting too much. And this is because
here in the tile size, we have to define how
large the tiles are. Now these tiles specifically
I found them on do ins, I think it's called
Dungeon Pixel tiles or something like that, but basically on ho you
can find three tiles, two D art here, it was 16 by 16, that's what the artist wrote. Also, if you write 16 by 16 pixels, so these are
pixels you can see now you are selecting
them correctly. Now if I click on the tiles, they are getting
selected correctly, Now they are prepared. Later on we need to add
collision here, inside of here. Maybe we need it,
maybe we don't. Because it is a clicker
game and no one is moving. I actually don't
think we need to add any collision to the game. This was it for now. We can now just go ahead and save everything
and close it down. Now if we need the
props later on, let's actually do it
now. We might use them. Let's right click here.
Go to Sprite Actions, Create a tile set from
this one as well. Go ahead and rename it to S
in the beginning tile set. Let's open it up inside of here. Again, you can see when
I select something, it's selecting too much. This is because the tile size
is 16 pixels by 16 pixels. Now when I select the items, it is more correct and
it is not selecting the item beside it as
well. That was it for now. Go ahead and save
this one as well. Now if you decide to go
to Cho in the future, and you can just go up here in the brows games and assets, and here you can
find free assets and you can download them. But you can do here as well. This is basically the
one I downloaded, this spec here. But basically if you want more tiles later on for your game or you need
more props for your game, you can always go in
here, download them, and again import them. Remember to right click, apply paper to the
setting texture settings to make them non blurry. And then right click, go ahead and create
a tile set again. And there you have
your new tiles. Okay, so now we can use
those to make our tile map. So let's go ahead in the next lesson and
create a tile map.
9. 2.05 Creating a Tile Map: Now that we have
created the tile set, I'm just going to
take those here and move them over to the
Environment folder instead, outside of the Textures folder. Because basically those
we don't need anymore, But you don't need to
delete them because these tile sets still
need those textures. But we're not really going
to use them in the game, we're going to use this here. Let's now make a tile map. If you right click on your
tile set here that we created, the dungeon prism, you can
create a tile map up here. Go ahead and create a tile map, and I'm going to call it
again, Dungeon Prison. Let's stop, click and open
it up and see what it is. As I told you before, a
tile map is the canvas. You paint the tiles
on the tile set, which you can see here to
the left is your canvas. You can select tiles here,
can zoom in and out, You can hold right click, and you can pen
around, for example. You can take the floor
here if you click here. If you move the mouse to
your canvas in the tile map, and you click here, now you can see you have
painted a tile. You can just left
click and paint. Now you can see you have
filled the whole thing. Now if you want to erase, you can click on
the Erasor up here, or you can click on
E on the keyboard. Clicking on, we'll select the razor again,
click on everything. Or you can press on, and that will fill
the whole thing. Or you can click on it up
here, the paint bucket. And you can click
here and it will fill the whole canvas with the
tile you have selected. You can also select
another tile, and clicking on B
for the paint tool, then you can paint here as well. Now I can see we can
paint inside of here. To the right, we have layers. If you have worked with
software like Photoshop, you know what layers is. For example, let's say I
painted this ground here. Clicking on this
tile, I painted here. If I click up here, you can basically
switch tile sets. I can switch my tile set from dungeon prison to
the props I created. Let's say I want to
paint this here. You see here. If I click here, it's not enough
because the crate consists of this
one and this one. I can actually just click and drag and just select
both of them. Now if I take them
here and I paint, you can see my ground
is getting deleted. This is because you're
painting up here as well. I'm going to click on control Z. So instead of here, let's add a new layer. Now I can paint my bucket
on this new layer. Now you can see nothing happens. This is because this layer is not affecting the
layer beneath it. If I click on the eye to
tuggle the visibility, now you can see I hit my crate. And if I click it
again, I show it. And I can do the same
thing with other items. I can basically click on the
second layer and add it, and it will be just fine. Now you can see if I click on the first layer and I paint it, it will delete the
tile beneath it. Very, very nice to
have these layers. If you need something on top
of the layer beneath it, I need something on
top of the ground and I have to make a new layer. Let's say we had a game where
we had a sky and clouds. Let's say it was a platform
or game and we had cloud. Let me just delete
all of those here. Let's say we had clouds here. And behind those tiles as well, we could have created a layer. And actually we could
click on this arrow to place the layer behind
these tiles here. And we could paint behind it
without it being affected. And you can see if
I hide them here, these are actually
behind the ground tiles. Okay, so this is how layers
work, just like in Photoshop, if you have worked
with Photoshop before, let's just go ahead and delete this layer here. And
this layer as well, just keep this one.
Now down here we have to define the
tile width and height. Now this is correct because remember inside of the tile set, we had the tiles to be
16 pixels by 16 pixels. And here it is also 16
pixels by 16 pixels. So this one is correct. Okay, let's go ahead
and delete this. I'm going to click
on E for the razor. Just go and erase everything. Now what we can do is
everything is good. The map width and height. Let's just make the
map a bit larger. I'm going to make
it 15 by 15 tile, size 15 tiles by 15 tiles. This is just temporary. You will create a temporary map which we will change later. Don't worry about it for now. We just want the game to have something so we
can code the game. For now, this is
fine. Let's click on File and save everything. And let's move on
to the next lesson.
10. 2.06 Designing a Temporary Tile Map: All right, let's go ahead
and design a temporary map. Before we can code our game, we need to have something here. Basically, let's click on
the tile set up here and select the dungeon prism inside. You can select
whatever you want. You can even take this one and click on
for the fill tool. And you can click here
and you are done. But basically I'm just going to create here doesn't really
have to be something good, because we're going
to change it anyway. I'm going to click on and fill
it here with these tiles. This layer one, You
can even click on it. Click on two on the keyboard
and call it base layer. This is maybe the ground. Now we also need maybe some
walls. These are the walls. I'm just going to select
this corner here again. You can click and drag,
select all three. You can click on this plus
here, make a new layer. And I'm just going to
call it front layer. Maybe click on the pin tool
to paint, paint it here. I'm going to select walls Now, going to just click and drag my mouse to paint
all of them here. Again, select this one
and paint it here. Okay. Now sometimes when
you have new tiles, you have to figure
out which goes where, because they are very specific. For example, down here
is, I think this one. You can select this down
here, paint over here. Then you have to select, let's see, I think it's
this one. This one. Paint down here as well. You have to select
one of them here. We have to se, let me see here. If we can find one that
fits, maybe this one. Yes, this one fits. You can paint it over here. You can select this click
here, paint it upwards. Now just connect and connect
it with this one over here. Now we have a small
room we can work with. You can even try to practice these tiles. It's
good to practice. Now, before you
make the final map, maybe add something
like this here. But as you can see, we
actually on the sides here. Let me see if we can fix this. Maybe you can paint
with this one. For the other side, I
need to select the ones, let me just so you can see better the ones in
them on this side. And now it is looking correct. Okay. As well for the tiles. Let's see if we need to paint those now We don't really
need those, I believe. All right, so what
we can add as well, you can try to add this
one if you want to. Basically, we can click and dry and select all
of them like this, and now we can add
them again here. You can try to add them
to the base layer, but as you can see, you will paint on top of here. Click on Control, you can also
see it's behind the wall. Click on the front layer, you
can try to paint it here. As you can see, again, it's
painting on top of the walls, because we're painting on top of those layers or those tiles
clicking here and adding a new layer and maybe call it decoration
front or whatever. It's not really too important,
Whatever you call it. Let's, let's just add
it here, for example. Now you can see we
have added this. As I can see, the tiles I just selected. The tiles here up
here is not fitting, so we need to go
to the base layer. And I'm going to go
up to the tiles here. And I need to paint with these tiles. Painting
with these tiles. And the corner tile is here, the other corner is here. Let's try to paint it correctly. I think this one is here. Let's paint this one here. Again, this corner like this. And I'm just going to
paint around like this. Okay? I can do it very quickly. Right now, it is not
really too important. This is just a test map
which we will change later. Now the bad thing about
honoral engine for picks a lot so far is if you
paint wrong things, if you click on control Z, it's only going to remove
one tile at a time. If you do it too much,
it can be a pain. All right, this tile here, maybe we just need to paint
this one instead like this. And it's looking a lot
better here as well. Now it's looking good.
I believe we also have some highlight
for the pillars. We can see the pillar
also has some highlight. I can actually select this one, go back to the front layer, and I can paint this
one as the pillar. We have some light
from this room here, the red light, and it's
looking more realistic. Now, if you also want
to add some props, again, doesn't really
matter right now. But you can add some props
here. For example, create. You can go to the
decoration front. Let's place one here. Maybe place this one
side, it's like this. And maybe in the
corner, let's see here. We can place this chest maybe here in the
corner like this. Again, it doesn't
really matter for now. Let's just leave
it be like this. If you want to add some grass, I could see there
was some grass. You can maybe select
some of it here. Add the grass down here. Then you can finish it off, I believe by hinting
with this one. You can paint it here as well. I'm going to click on Controls. Not too important right now. Let's save everything. And this is the
map that we have. Let's close it, and let's
go over to the next lesson.
11. 2.07 Placing the Tile Map in the Level: Now that we have
created the tile map, let's click and drag
this into the level. Very easy. This is how you place the tile map into the level. Again, just like I
told you before, you can hold the right
click and click on W D S and A to move around. Basically, this is actually
what it looks like. This is two D inside
of anual engine. Since it's a three D
software or three D engine, this is what it looks like. We're working with
three D, but if you go to the orthographic view and view it from the right view instead of the wireframe mode, you can just select
the unlit mode. You can zoom in here and you can see this is
what it looks like. And now we're viewing it in two D. I'm just going to go back to the
perspective mode for now. What I usually do
for the location, I said at 20, let's write 000. It is here at the
zero in the world. I'm going to remove all of these lines here because
I don't really need them. If you click on the tile map, you go down here, you
can remove this one, Show per tile grid
when selected. Now it is removed. Now
this is how you place it. Very easy. We can
go ahead and click File and save all.
But as you can see, it is looking very bad because the colors
are not correct, and this is because
the lighting in Unreal Engine is
affecting this tile map. So let's go ahead and fix
it in the next lesson.
12. 2.08 Post Process Volume: Now to adjust the lighting, we have to use something
called a post process volume. If you click up here
and you go to volumes, you can find something called a post process volume down here. You can also find it
inside of visual effects. This one post process
volume is the same one. You can click on it and
you will create one. What a post process volume is, if you have worked
with Photoshop before, it basically changes the colors, just like in Photoshop. You change the
saturation of the image, You change the lighting
and brightness, and so on. It's the same thing with the post process volume.
You click on it. Inside of a post process volume, you can change the Bloom amount the exposure if you
want a lens flare. The image effect which is the vignette around the image
where you make the image, aka on the corners, and it makes like a
cinematic effect. And you can change the
temperature of the light. You can change a lot of things where you change
the look of the game. Post process volume is used to change the
look of the game. Okay, Inside of here, if you just increase
and decrease the value. For example, if I go to Bloom and I click on the
intensity and I increase, decrease it, you see
nothing happens. This is because you have to go inside of a post
process volume. And as you can see,
if I'm inside of it, I can now increase and decrease and it changes the values. Now, instead of being inside
of it here you can go down and then you can find this one called Infinite Extent Unbound. If you click on it, this means that it will affect
the whole level. And it doesn't matter if you're inside of it or
you're outside of it, it's going to affect
the whole level. Now you can see if I
increase and decrease, the intensity is
going to change. Now the good thing about
being inside of it is, let's say you had
a three D game or even a two D game like if you want to make
a special style. If you go into a cave
in a three D game, for example RPG game, it changes the look of the game because now you're
inside of the cave. The cave has a
specific look to it. If you go outside of the
cave, it changes the look. But here we don't really need to change effects
depending on where we are. We want the whole
thing to be the same. Usually in most games
we just click on infinite extent unbound and
we affect the whole game. Okay, now for the Bloom, I need to set it to zero
because we don't really have Bloom or in two D again with two D inside of a three
D engine is really cool because you can use the D
lighting and add that to two D, which then gives it really
special effects that, that you don't get
from two engines. You can get three D lighting, you can get three D
effects inside of here, which you can't get
in two D engines. Very cool to experiment
with that as well. I'll probably create a course later if I haven't
already created one, on how to add special
three D effects to two D. But for now, let's set the Bloom to zero. Let's go to exposure and basically the minimum
and maximum exposure, usually I set it to 1.1 exposure is simply
if I disable it. You can see the lighting
increases with time. This is good for cinematic
three D environments, but we don't really need
to change the lighting depending on if we're close
or if we're far away. So let's just set
it to a constant, even though we're close or far away, it
doesn't really matter. But for now, I'm
going to set it to two because I'm
just going to give you my post process
volume settings that I created for
two D inside of here. The lighting is very, very good because as
you can see here, we have to adjust
the lighting and we want to make it
look like the unlit. If you go to the unlit, this is what it looks
like without lighting. This is actually what this
pixel o tile set I have. This is what it
looks like truly. You can also see it
inside of the right view, in the autographic view. If you zoom in, this
is what it will look like when we have
the lighting correct. If we go back to the
perspective mode and I go back to the lit mode, the problem is when you
click on play here, you only see it in the lit mode. We actually have to
change the lighting in the lit mode to be the
same as the unlit mode. This is what we're trying to do with the post process volume. We're trying to
make the lit mode look the same as the
unlit mode. Like this. Okay, let's go to
the lit mode here. I've tried for three to 4 hours. I was just playing with a lot of settings here to make it
look like the unlit mode. I found out that the minimum
and maximum exposure should be set to two. The image effect, which is
basically the vignette, you can see, it adds like a cinematic effect
around the edges. We just sat this one to zero,
we don't really need it. We have actually up here, the highlights and
the miscellaneous inside of the color grading
for the highlights minimum, we need to set this to one. Let's see here for the
tone curve amount, we need to set it to zero. You can see a lot of difference when we
set this one to zero. It almost looks like
the original one. Now if you go to the Lit mode. When you go to the Lit mode, you can see it looks a
lot better than before. However, we still need to adjust some things because you can
see it is not the same. You can also click
on the shortcuts, old four and old three. If I click on old three, I go to the Lit mode. Old four, I go to
the Lit mode, there, can click old 3.4 very quickly, and you can see the
difference between them. There's still some difference if I go back to the Lit mode. And let's change some
settings here as well. Now, up here, actually down
here, let's just continue. Before I change the
colors down here, let's change the ambient
occlusion intensity to zero. Also, let's change the motion blur amount to zero as well. Really need that. Let's click on File and save everything. Now if I go up here, we have something
called temperature, global shadows and mid tones
under the color grading. Now we are ready to
change the colors, maybe reduce the saturation. Because as you can see here, if I go to the unlit mode, it looks a bit more
unsaturated than the Lit mode. Now, I've given you the
correct settings for this one. This one has to be 1.0 All of this we have set to zero because we don't
really need them. And the exposure is set to two. But now you have
to go on your own, because you have to set those depending on what
your tiles look like. Remember the global here, if I just opened the global,
actually not all of this. If I open the global and
you open up the saturation, the contrast, the gamma, and also opening up
the gain here as well. Let's work with those and
fix what it looks like here. Let's start with the saturation. This is because I look at this
red here in the Lit mode, and I click on Unlit. I can see it's more
easy on the ice, which means it's less saturated. If I go to the Lit mode and I go to the saturation
and take it here, now you can increase and
decrease the saturation. And you can see you
can change the look. However, we don't really need
to decrease it this much. I'm going to go back
to one like before. And what you need to do
is again hold Alt and click 3.4 You can switch
between the Lit and on Lit, and you can see what it looks
like if I click on Here. On the Lit mode, I decrease it a bit like this and I
click on old three. Now you can see
what it looks like. I'm just looking
at this red here. Maybe instead of
having it like this, I'm just going to have it to 95. Okay. Click on old 3.4 switch
between them very quickly. You can see that,
what it looks like. I think the saturation
is fine now, but I can see it is more,
it's more white here. I think it's the
gamma and the gain. Let's try to go to the gamma here and let's increase it slightly because
you can see the gamma. If you increase it too much, I go back to the lit mode
and increase the gamma. You can see this is the effect. What you can do is a trick
that I use sometimes. As I click old 3.4 I
just keep clicking it while I actually adjust here you can see if you adjust it in a wrong
way, too much. You can see it far
away from each other. If you increase it too high, it's also far away
from each other. What I usually do is I hold old and press 3.4 very quickly. I just try to have them as close as
possible to each other. Now you can see
if I click on all 3.4 to switch between the Lit and Let they're
almost the same. 1.05 is the correct value here. Now for the contrast,
I can try to click here and try to increase
the contrast slightly. I'm going to increase it again. Al three like this. 1.02 I think is the correct one. Now for the gain, I
think we can give it a little bit for the gain.
Let's try that as well. Something like this
here for the shadows. Now, if you want to
give the shadows a bit more contrast
or remove contrast, you can actually do that if
you click on the shadows. If I go to contrast, because if I look at my shadows, I'm just looking at
my shadows here. I think it is too. Contrast on the lit mode, you can see it's
lighter on the lit. But if you go to
the lit mode, it's, we can decrease the contrast for the shadows a little bit. If I again click on old 3.4 I just keep clicking them
to see what it looks like. This is way too much,
maybe something like this. Just 0.97 Again, as you
can see from my values, I'm not really changing
them too much. Maybe 0.020 0.05 and so on. So not changing it too much, just slightly, so I
can have that look. Now if I go from the unlit
mode to the lit mode, you can see it's very close. Now, you can spend more
time than what I have here. You can maybe spend 15
minutes or 30 minutes try to adjust back and forth
here and have better values. But for now, everything
is looking good. However, we still need to adjust some settings inside of
the project settings. And let's do that
in the next lesson.
13. 2.09 Adjust the Project Settings: The final thing we need to
do to the environment right now is we need to
disable tasing. Now as you can see here, maybe it's not
really too visible, but there is anti eliasing which blurs things a bit and it
doesn't look like Pixelot. This is again done
because in three D T elising is really good and it makes your
game look better, but in Pixelot we
don't really need it. Let's go to the Edit and
go to Project Settings. Inside of here, we
need to go down and find the Rendering tab. Clicking on Rendering, let's
try to change some settings here for the mobile
anti eliacing doesn't really matter right now. We're not creating
a mobile game, but it's good to know
that it's there. And you can always click
here and set it to none, because we don't really
need anti elycingw. If I go down here and I take a look at the settings,
everything is fine here. Don't really need it
now for the lighting. Let's just set it
to none instead of lumen. Let's set it to none. We don't really need
reflection as well or two D. Let's take
a look down here. Everything is looking good. You can disable Nanite
if you want to, which is the three D models, the new system in
non religion five, let's just restart later. For now, let's just
take a look here. Everything is looking great. Now the most important thing is here in the default
settings now we already disabled or ambient
ooclusion and so on. We don't really need
to worry about those. We did that inside of
the post process volume, the motion blur as well, but you can disable it
as well here if you wish to bloom and ambient
occlusion if you want to. But it doesn't really
matter here in the anti eliasing, this
is the important one. This one you want to set to non, you can see the difference. If I take a look up here, now I can set it to non, you can see the difference. You can see it
gives jagged lines. If I set it to this
one for example, or this one super
is the default one, you can see this is
what it looks like. You can set it to none or you
can set it to one of those, but none is the best one. For pixel, it looks a
lot better like pixel. Okay, awesome. Now it looks good. And this one as well. You can set it to nothing here. No AA, everything else is fine. Let's one. And I'm going to
hit Restart Now. Once it has restarted, you can see we are
inside of here. Now it opens up this
open world level by default and you
can change this if you go to Edit and
Project Settings. And you go to the
maps and modes here. And you can change the editor start up map to be your map, Dungeon the Editor,
game, default map. You can change to
map Dungeon as well. Now you can close it down
and save everything. Next time you open
up the engine, it's going to automatically
open your dungeon map. Now let's click on
it. Double click on the map to enter it again. Now everything is
looking good again. You can click on, you can click on Let's here on this one. And you can click
on the right view. You can go back to
the perspective. Click on Lit mode. Lit mode. There is a slight difference
here in the edges, but I think it's fine for now. You can see almost no
difference. It's looking good. So now we can click on
Play and we can play this game here and have
the correct lighting. Okay, Everything's looking good. As you can see,
again in Picsalot, you have layers in on real engine because
it's a three D engine. If I just reduce the camera
speed, it looks like this. It looks weird because the front layer is in
front of this one. Basically. This is
when you created the layers inside of the
tile map, these layers. This is what you see here. This is the decoration
front layer. This is the decoration layer, or the front layer, and this is the base layer. You can
see them like this. It looks weird. But when you click on play and not like this, but when you click
on play, we make a real camera. It
will look like this. It looks all two D because we're looking at
it from the front, everything is looking good. Let's click on File
and save everything. Let's get started
in the next lesson.
14. 3.01 Game Mode & Player Controller: All right, so now that we have finished designing
the environment, let's go ahead and
program the game. Now the first thing
here is I see a message saying that nanite is enabled
but cannot render. And this is because we disabled nant here in the
project settings. If you search for nanite, remember we disabled it here, it says it's still enabled. Down here in the con, you see here at the
bottom you write nitro and I'm going to enter and it's going
to disable nanite. And also this message is gone. Let's go over here in
the content folder. Let's right click and
make a new folder. Let's call this one blueprints
inside of this folder. Now let's right click, and now we are ready
to program the game. The programming is
blueprints in real engines. Go ahead and click on
the blueprint class. Let's make one. Now you get these options
that you can make. Now, it might be a
bit confusing at first if you haven't
used blueprints before, but just to go very
quickly through them, the actor class that
we can make here is an object that can be placed
or spawned in the world. It's basically just
a static item. For example, a table, a flask, anything that is not
moving in the game, for example, this box here
is not a moving object. This is an actor. A pawn and a character are two classes
where you can create them. If you need movement, you
can see a Paw is an actor that can be possessed and receive input from a controller. Let's say for example
in your game, this is the player. And the player can move
around with this box here, you can roll around
with this box. Then you actually need to
create a pawn and actor. Because if you create an actor, you cannot control it
with your keyboard. If you need to control
it with your keyboard, if it's a player, you
need to make a pawn. However, if you
have a character, something with two arms and two legs and you
need to walk around, you need to create
a character and not a pawn is for example, if your game is, if you're
like a box rolling around. Or if you're like a
ball rolling around, so you don't have
two arms, two legs. As a character, you
can create a pawn. However, if you have this
typical humanoid character, it is a character that
you need to make. Now we are going to create a Player controller and a
game mode in this lesson. And a Player Controller
is an Acta that is responsible for controlling
upon used by the player. Now it might be a bit confusing, This is not your controller, Xbox controller, or your
Playstation controller. You can think of it
as the brain for the character when you
spawn into the game. Every character that you
spawn as a player controller, it's not only the character
when you get into the game. If the player joins the game, the player controller is
created automatically for you before the character is created. Very, very
important to know. Usually what we do in
player controllers is we code the user
interfaces, the UI. We also do the spawning. For example, if I spawn
a weapon into the game, if I spawn a coin, I spawn anything into my game. I usually do that in
the Player Controller. Now, some people also do movement in Player
controller, However, I suggest that movement
is done in the character, because in multiplayer now
we're not coding multiplayer. But in the future, if you want to code multiplayer, it's always nice to
get used to one thing. In multiplayer, the
movement has to be in the blueprint class. If you do movement code inside
of the black controller, in multiplayer, it's
not going to work. I always do movement
in character because it also works a
multiplier in the future. If you want to do anything
with multiplayer, this is the black controller and the game mode is defines
the game being played, its rules, scoring and
other facets of the game. For example, let's
say in counterstrike you have a round timer. And how many points do you get when you kill a
player and things like that. Rules about the game is
usually done in the game mode. Now let's go ahead and click on the game mode and make one. Usually I give them BP as
a prefix for blueprints. However, for the game mode I
usually write GM game mode. And I call it the
name of the game, which is Dungeon Clicker. Let's call it Dungeon Liquor. Let's write click again, make a new blueprint class
and make a Player Controller, let's call it PC for
Player Controller. Let's call it again the
name of the game, Liquor. Now you can have
multiple game modes. It's not because you
can have one game mode, for example, again
in Counter Strike. In other games like Halo, you have a game mode where
you have three for all, everyone can kill each other. You have a game mode where
you capture the flag, each team captures the
flag to their base. Different game modes. You can
have multiple game modes. However, we are
doing a simple game. We only need one though. I usually just call it the
name of the game here. Let's go ahead and
save everything. Now that we have this finished, we actually don't need to
do anything inside of them. However, we need to assign the game mode to be used
inside of Unreal Engine, because right now it is using the default game mode that it creates when
I open the engine. Let's go ahead and click on Edit and open the
Project settings. Inside of here, let's
go to Maps and Modes. In Maps and modes, you can see the default game
mode being used. Is the default game mode
within Unreal Engine. I'm going to tell it no, I want to use my own. I want to use this
one GM clicker. Let's minimize this for now. Instead of here, let me
open up my game mode. It opened up here in my second monitor in the
game mode in class defaults, we need to change the Player Controller we
also made because now it's using the default Player controller
in Unreal Engine. However, I want to use
my custom one I created, which is the PC Dung clicker. Let's go ahead and compile. By the way, just
means that you're checking if your code
has any box or not. If you click it, it
says it's good to go, everything is good ahead and click on File and Save
All. Let's close this down. Now. Let me just open
up my project settings again and make sure if I click on the selected
game mode down here, that my player control is also assigned in my
project settings. And it usually is when you do
that in the player control. Okay, let's close it down here. The last thing we need to do is here in the World Settings. By the way, if you don't
have a World Settings tab, go ahead and click on, let's see here, the
window up here. And open up the World
Settings From here, let's click on the World
Settings and also in the World Settings in
the game mode Override, click here and assign
your GM dungeon clicker, which is the custom game mode. And you can also make
sure when you click down here that your player
controller is assigned as well. All right, so let's
go ahead and save. And now our custom game mode is assigned to the
map or to the game. We can't really do much
because we haven't really done any coding. So we can't see if it
actually works or not, but we are going to
do that very soon. Now we have finished
adding the game mode and the player controller and we are ready to add the player camera.
15. 3.02 Adding the Player Camera: To add the player camera. Let's right click again
inside blueprints, and let's create a
blueprint glass once again. Now for the player camera, you can create it as a pawn. Because we don't really have
a character with two arms, two legs to walk around, you can technically
create it as a pawn. However, I like to create the player cameras also
for my other games as a player character because it comes with a character
movement component. That one, you can control
the gravity of the camera, the movement speed of
the camera, and so on. You'll see what I mean, but this one gives me more options. I usually just
create a character. Let's call this one P player. I call it camera, but I'm just going
to call it player. Let's go ahead and open it up. And here we are
usually in blueprints. When you open it up, you have the viewpoint here where
you can see the character. If you import, you can see here to the right in
the details panel. It almost looks like the
details panel over here. It's the same thing where you click on things and then you can see different options
here for the mesh. You import a character, you could see the character
here in the viewport, just like you have a
viewpoint over here. Okay, inside of this BP player, we need to create a camera. By the way, the character
movement component is here. If you click on it, you
can see you can control things like the
acceleration of the player, which in this case
is the camera. You can control the
ground friction, the maximum movement
speed for the camera, and a lot of things, the air control, and so on. I like to create a character instead of
a Paw or the camera because I have this
character movement component and I can control my
camera a lot more. We need to create a camera. Let's click on Add Up here and the components First
before the camera. Let's create something
called a spring. If you create a spring here, this is the holder
for the camera. Now clicking on the spring arm, I'm going to click on D and search for camera
and create a camera. We have the spring arm,
which is the holder, and then we have the
camera over here. Let's click on Compile,
and let's click on Save Everything. Let
me minimize this. Let me just drag
this player into the world like this.
Here is the camera. If you can see it
in the background, but it's dark so
we can't see much. I'm going to write the
location for it as 000. Also rotate my camera, You can see it's
looking this way. I'm going to go
back to my player. I'm going to click on my spring, not my camera but my spring. I'm going to rotate it When I
click on the rotation tool. Remember the tools up here
is for the move tool, for the rotation tool, and R on the keyboard
for the scale tool. Clicking on for
the rotation tool, I'm going to rotate it this way. Now I'm going to compile
again if you minimize it. Now your camera is
looking the correct way. You can also see
it in the viewer. When you click on the camera, now it's hiding here
because everything is dark. I click on Lit, you
can see it's here. If I click on it, you
also see the viewer. For the camera down here, you can just move
the camera you wish, You can see it in
the viewer here. Now, before we align it, you can see in the camera, if I right click the camera
and I click on Pilot, which means go into the
camera and see what it sees. You can see that the tiles
are cutting off here. It's not looking two D, it's actually looking three D. I click on this button up
here to get out of my camera. I opened the player again. This is because when you
click on the camera, you actually have to change the projection mode from
perspective to authographic. Perspective is the three D mode, orthographic is the two D view. We need the two D view here. Let's compile and
let's take a look. Once again, you can see
now it looks correct. If I right click my camera
and I click on pile it, I think you can do
it up here as well. You can right click up here in the Outliner as well
and click on pile It. Now you can see it
looks more correct. It two D also looks good. Let's get out of here.
Let's open up the player. The last thing I want
to tell you here, we don't really have
much to do anymore. But here in the camera, you can change the
orthographic width. And you can see what it
does if you click on your camera up here
in the BP player, and you increase and decrease
the orthographic width. If I increase, increase, you
can see you zoom in and out. Pixel Ot, it looks more
or more pixelated. The lower the
autographic wood is, this is maybe how you
want your game to be. You can make it more high res when you zoom out like this. Now for my game, I tried
just to play with it when I was testing it and I think I'll stay with
something like 640. If I just right click my
camera and I pilot my camera, this is what it will look like. I can take my player here and
I can adjust the location. Remember, we could
adjust the location by clicking on the numbers here in the location
for the player. And we can click and drag with the mouse to see
what it looks like. I can do something like this. Actually for the
Y, it's just zero. For this one it's like this. Awesome. Now it is censored. Not really too
important right now. We're going to fix the
positioning later. But for the player, again, just to make sure
everything is working correctly for the spring, I'm going to disable
the collision testing. Ucision testing is simply when a player is
behind the wall. It's going to push the camera, so the camera is not
going into the wall. We don't really need this
because it can buck the game. Right now, I'm going
to disable it. The second thing is the capsule. I want to remove
all the collisions, because I don't want
this capsule to collide with my enemies or characters inside
of this world. We don't really need this one. I'm going to go
down here and make sure that in the
collision section for the capsule generate
overlap events off or the collision
presets here. Instead of pawn I'm going to say no collision that is fixed. Now in the mesh itself here. I'm just making
sure that also in the collision it's so he
can character step up on no and no collision as well.
Go ahead and compile. Now for the spring arm, we did remove the
collision test. The final thing here in the player character
movement component, let's make the gravity
to zero because we don't need this camera to
fall down or move around. The maximum
acceleration is zero. Let's see if we need
to do more here. I don't think we
need to do more. Everything is looking good. The maximum speed
doesn't really matter. You're not going to walk around. But you can just set it to
zero so you can't move around as well if you wish to.
Let's just compile, save everything. And that
was it for the player. Now it is set up. You can control how far away your camera is to your liking. So if you wish the camera to be a lot closer, you can do that. For example, you can
click on the camera and set the autographic
view to 512. And you can see it's
a lot closer here. Not too important right now. We can always test the game whenever we have a
character moving around.
16. 3.03 Extracting the Enemy Sprites: Let's now go ahead and import these prices for the enemies. Again, let's go back to the cost materials folder
that I've given to you. Inside of here,
go to characters. Here are all the enemies
that we have in the game. Now in the future, we
can add more enemies, because in clicker games you have tons and tons of enemies. But these are really
nice to start with. Let's go ahead and
click on the first one. Hold Shift, click on the last
one to select all of them. Let's go to the Assets. And here I'm going to write, Click and make a new
folder called Characters. Inside of here as well, I'm
going to right click make a new folder once again and
let's call this one Textures. Let's go inside of this folder. And now we're going to click and drag this into the
Textures folder. And here we have
imported all of them. All right, Clicking on the
first one again, hold Shift, click on the last
one, right click, go to Sprite actions. And remember to apply the
paper to the settings, else it will be a blurry texture to apply to the settings. When you do that, the art is fix a lot, it's
looking great. Okay, let's close
everything down here. Let's click on File
and save everything. Now that we have
imported everything, what you need to do, you can see here they are all
in one texture. If I opened the first one, the Night Death, you can see
they are in one texture. We need to have them
as separate sprites. Let's close this
down. I can right click on this Night
Death. Here I can go. Sprite actions, you have
something called either create sprite or you can
extract the sprites. Creating a sprite is
simply, for example, let's say you had
one character here and you didn't have them
all together like this. You could right click sprite
actions and create a sprite. When you do that, it
creates this sprite here. When you create a sprite, you can actually use it in game. You can click and drag
it into the world. If I just move it
here to the front, I can see it like this. Now see I can use it in my game, for example, if you had a
box or things like that. If you have a singular object, you can right click and
create it as a sprite. And then it's basically just like making
a three D object, which you can use in the world
because this texture here, you can't use it in here. You can see it replaces
this and it creates some material for us and things like that,
everything is messed up. I'm going to click on
control Z to revert it. I'm just going to delay
this one it created. You can't use textures
in the game like this. You have to click, make them into a sprite, for example, if you have a box or something static
you want in the game. And you can drag it into here and you can use it as a sprite. However, let me delete this one, and let me also delete this one. Now they are all together. Instead of creating a sprite,
we need to extract it. Right click, go
to sprite actions and extract the sprites. And you can see them
up here like this. What we need to do is up
here in the settings, we need to make it into a grid. Now we have to figure
out in the sil, width and height,
what the size is. Usually the artist who makes this writes
to you what it is. But let's try to make it 32 excels like it is for
the height 32 here. Now you can see it's not fitting because every box needs to
be around this character. Instead of 32, let's
say plus 16 pixels. The good thing about
Unreal Engine, you can actually write
plus 16 and hit Enter, and it's going to do that
automatically for you. Okay, 16 pixels worked because now you can see
everything is looking correct. Every single sprite
is in its own box. This is the correct
cell width and height. And let's go ahead
and click on Extract. Now you can see it
extracted those here, and now they are in
singular images. Now if I click and drag
this into the world, it's a single character that is out here instead
of the whole thing. We actually need to do that
for every single one of them. For example, the night hit, you can right click and you
can go to sprite actions, go to extract sprites again, click on grid instead. Then you can click here. I think it's the same,
maybe 48 as before. But if you write 48, you can see it's
actually not correct. If I go back to 32, like the height, you can see
32 is the correct one here. And you have to
click extract here. Okay, let's try
with the final one. Let's right click the night idle to extract sprites doom in. Go to grid. I think it is
32 again, just like before. Now go ahead and
click on Extract. I'll show you this one as well. After that, I'm just going to do every one of them quickly.
You can see it takes time. I have to do it for
every single one. But let's right click this one. Go to Spart, actions
extract sprites. Now for this one,
let's click on grid. Let's write 64, just
like the height there. It's a good starting point
to just write the number of the height and you can see it's already working correctly. And extract everything right. Click Extract
sprites, go to grid. You can see you'll get very good at it because you
do it 100 times. Sometimes even if you're sleepy, you can do it without even
thinking what you're doing. Just doing it a lot of
times is good practice. Now we extracted those. I believe if I just go
back to the folder, this one, hit this one, idle, base idle, extract the sprites to grid 32, that works, okay. This is what you need to do
for every single one of them. Try to fit them into the box
and extract all of them. Okay, I'm going to do it on
my own time and I'll be back with you right now. I have extracted all of them. Now you can see all of
them are extracted. It's a bit tricky sometimes to know the sizes of them
when you extract them. But basically, again, if you open one of them, for
example this one, this one was the most
tricky one if you write, click and extract this price for this one, you
can see it here. If you go to grid 64 again, right, 64 is a good
starting point. You can see it's not correct
because this here is empty. We don't need empty ones. If you write plus 16, usually it's 16 pixels every time you
increase or decrease. And this one is not
fitting either. Plus 16. Again, now we can see it
fits with all of them. Okay, just go ahead and
do it for all of them. I have done it for all of them. Now let's go in the next
lesson and create flip books.
17. 3.04 Creating Flipbooks: All right, so now that we
have the sprites ready, let's go ahead and
create flip books. And flip books are simply the
animated version of those. We're putting all
of those sprites together into an animated piece. The character is moving.
This is a flip book. A flip book is simply when
you need an animation in two D. Let's try it
with this night Death. First click on the first
sprite and you can see, by the way, the textures, they have a red line here. And if I zoom in,
you can see it. They have a red line
here the textures, while the sprites have a
light blue line here or teal. This is the sprite. You can see the
difference between them like this as well. Clicking on the first one,
I'm going to Old Shift and click on the last
sprite in this section, I'm going to right click, go to Create flip book. Let me call this one
B for flip book. Let's call it, let's
call it death. We have this flip book, death. And you can see it's already animated. I double click on it. This is the death
animation for the night. A flip book is simply just the sprites put
together into an animation. You can see, I can just
stop it down here. This is the animation and
these are all the sprites that we selected and created a
flip book for. All right. You can also see if
I play it again, you can control the speed of the animation here in the
frames per second, I can, for example, set it
to 50 very fast. If I just said the frames
per second back to 15, this is the default, this
is what it looks like. Now there's really a rule
for what this should be. Sometimes the pixilatist write to you what it is
supposed to be here. But I'm just sometimes
just playing around, seeing how fast the
animation plays, and then I make this
into my game for me. I tried ten in
frames per second, and I think this is what
I want the speed to be. Now, there isn't a rule. You can go with 12,
you can go with 15, whatever you think is
good for your game. I'm going to go with ten for me. I'm going to close it down here. And now we have this flip book. Now we can click and drag
this into the character, and select Move Here, and now we have the
flip book out here. The reason, again, we made this Textures folder is
because all of this we don't really need to
look at later when we create all of the flip
books here for the characters. We don't need all of this
inside of the Textures folder. Again, you can't delete it because this is using
data from the textures. So you can't really delete them. I'm just putting them into a Textures folder so I don't
have to look at them again. But let's go in here. Let's
do that for all of them. For the hit, click
on the first one, hold shift, click
on the last one, right click, flip book. Call it again. Open it up, but you can do it later. Like you can change the
frames per second later. I'm not going to
do that for now. Go ahead in the next one, right click, flip book. Call it idle. Go to the next one
here, right click. Call it or I'm just going to
call it or instead of base, or go to the next one here, right click, flip book. Call it B. I'm just going to do some of them so you can see the workflow. And then I'm going to do
it again on my own time. Right click this one.
Flip book, call it. Or idle. Let's go down again
the next one here. I'm just going to do
this as the last one. Right click, flip book. Call it B or rogue. This is a rogue, like this. You can see they're
all animated here. Okay. I'm going to do
it on my own time. I'm just going to
create flip books and I'll be with you once again. Now, I created flip books for all of them as
you can see here. And I'm going to click on
File and save all of them. Now let's click
on the first one, Hold Shift, and click on the last flip
book inside of here. And I'm going to move them
out to the characters. Here we have all
of the flip books. Now let me adjust the
frames per second. Now instead of doing
it one by one, which takes a lot of time, you can click on the first
one and you can hold Shift. Click on the last one
to select all of them. Right click and you go to Asset Actions and
select this one. Edit Selection in Property
Matrix, select that. This is usually whenever you want to edit a setting
for each of them. It's always nice to write, click and use the
property matrix to change the same
settings for all of them. Inside of here in the sprite, I can change the frames per
second and make it ten. It enter and it does
it for all of them. Go ahead and click on
Save All, close it down. And you can see now
they are actually all ten in frames per second. This applies not only to flip
books, but to everything. For example, normal
texture where let's say I wanted to change the brightness
for all of the textures, You could select all of the textures, for
example this one. If I hold control, I select the next texture, this texture and this
texture I can write. Click Go to Asset Actions, Edit Selection via property
matrix here in the settings, for example, the adjustments. I could edit the brightness
for all of them at once. It always nice to know
this option is there. Okay, here are all the
flip books we created. All of them is looking great. If you forgot one of
them, it's no problem. We can always come back and create it as a flip book later, but I think I have
all of them now. Everything is looking great. Go ahead and save everything, and let's move on
to the next lesson.
18. 3.05 Parent vs Child Blueprint Class: Now that we have
created the flip books, let's go ahead and create
the blueprint classes. Let's go to blueprint folder. Let's right click
here. And let's make a new folder called enemies. First, let's go
into this folder. Right click, and now we can
create a new blueprint class. Let's go ahead and
create it here. Now instead of creating this
character for the enemy, this is a three D character. What we need to do is to make a two D character is
click on this small arrow with all classes Here
you can actually see more classes that you can
create with blueprint up. Here are the normal classes that you almost
create all the time. And you almost never go down here unless there are
some specific things. For example, when you make a save and load
game for your game, it's actually down here as well. Down here, we can
search for paper, which is the two D
in Unreal engine. We can see this one
called a papa character. This one is a three D character, and this one, the paper
character, is a two D character. You can also see we have other
things that we can create, such as flip books
we just created. You can create tile
maps, sprites, and so on, but we want
to create a character. Now let's click on it and go
ahead and click on Select. Now for this one, I'm going
to call it BP Enemy base. The reason I call
it Enemy base is because this is now
a parent class. I'll explain to you here
in this lesson what a parent class is and
what a child class is. Let's, for now, right click
here and you can see up here, it's called Create
child print class. Let's go ahead and create that. Let's for now call it BP knight. I'm basically just calling it
the characters that I have. If I go to my characters
folder, we have the night. Let's create the
next one as well. Or I'll explain what
a blueprint child is. Right click the enemy base, Create child, blueprint class. Let's call this one P Orc. Okay, let's go ahead
and save everything. Now I have this one here. The enemy base, if you hold
the mouse over the night, you can see the parent class is the BP enemy base. The
same thing with the Or. The parent class
is enemy BP base, or enemy base here. We can now open up
the enemy base. Let's say inside of
this blueprint class, I want to click on my
character movement component. So we have this
component because it is a character in here. Let's say I wanted to change how high my character can jump. You can see in the
details panel, you have things you can
change about the movement, the gravity, the maximum
speed, and so on. Let's say the
height of the jump, let's say my character, I wanted to jump a lot higher. If I, for example, click here and
write 800 instead. Now I can jump higher
if I click on Compile. Now if I minimize
this and I go to my children blueprint classes, these two are children
of the enemy base, because we right clicked and
created them as children. What does this mean? Now
if I go to the night now and I take a look here and click on the character
movement component. If I go down to the
jump velocity that I just changed on
the enemy base, you can see it is also 800 here. Now as default, if I go to the Or and I click on the character moving
component and I go down, I can see it is also set
to 800 in the Awesome. Interesting. Every time I change a setting
in the enemy base, which is the parent
blueprint class, This setting that
I change here is applied to all the children
that I create for it. And this is a very quick method to work with and also the
best one to work with, because I use this a lot. Imagine you have Fortnight and you have a lot of
skins in Fortnights. Let's say also here
in this clicker, you have 100 enemies. You create 100 of
these children here. Instead of going in every single of these
children and changing, let's say you wanted to change the gravity scale, 1.2 Instead, instead of going in
every single child and changing the value to 1.2
you can simply change the value inside of
the parent class and it will automatically apply to all the children for
it that you make. This is a quick way to work
if I click on my enemy base, and I just click
on this arrow to reset it to default to 420, and I compile and
save everything. Now if I go to my night, you can see it is also set to
420, the same with the Orc. This is an optimal way to work because you can imagine
if you have 100 enemies, it is a lot of work to click on every single one of these
hundred and change of value. You can simply change it once
inside of the enemy base. This is it for the parent
and children classes. Let's create the rest of them. We have the and we
have the night. Let's create the Shaman. Right click the enemy Create
child blueprint class. Let's call this one BP, Roku. Let's right click the
enemy base again. Create a child blueprint class. Call it BP or Shaman. Let's go back again. We
have to create all of them. We have the Warrior and we
have the Roque P Warrior. Now I'm just creating them a lot faster than before because
it's just the same thing. We're doing it again and again. The Skeleton mag and
the skeleton base, just calling it BP Skeleton. Like this. Skeleton
and the Skeleton mag. Skeleton mag. Let's see what we are missing. We have the Skeleton Rogue
and Skeleton Warrior. P Skeleton Rogue, BP
Skeleton Warrior. Just make sure
that you are right clicking the enemy base
and creating them. To make sure you can always
hold the mouse over it and it class is the enemy
base that is correct. Right click it here, make the
last one called BP wizard. Just to check if I've
missed anything. The wizard is the last
one and that is it. I know I have 11 characters. Just click here, Hold Shift,
click on the last one. You can see you have 11
selected and that is correct. I have 11 characters here. Okay, let's click on
File and Save All. Now we have created all of them. And this is looking good, so we are ready to continue
in the next lesson.
19. 3.06 Finalizing the Enemy Class Setup: Let's finish up the enemy. Now let's go to the night. We have to open them one by one. Let's open up the night
first, inside of here. If you're new to
blueprint clauses, basically what you
have are components. You have different components. For example, the sprite. Let's go to the
viewpoint for now. Here in the viewport, just like the viewport
here in the game. In the viewport for
the blueprint clause, you can see things visually. For example, the sprite, we haven't applied anything. And this is what we will do.
Now, let's actually do it. So you can see clicking
on this sprite, you can see it
needs a flip book. It is an animation because it is a character we created here. It needs an animated character
clicking on the flip book. Let, this is the night. We have to select
the night idle. Let's go ahead and select it. You can either select it like this or you can
click on the sprite. You can click and drag
here in the characters, you can click and drag this and drop it on top of
here. That works as well. Now you can see visually, you can move around, just like in the
viewport normally. You can see now we
have this character. If you double click on it, the framer per second. I did not change
it for this one. I believe I forgot to change it. Let me just select all of them. I think I changed it before. Anyway, select all of them. If you have the same
thing, right click, go to Asset actions. It selection in Property Matrix. I'm going to go to Sprite
and change the frame rate per second to be ten
frames per second. Let's go out and
let's close it down. Instead of going in
every single one of them and changing the frames
per second to ten, I'm just going to do that
by selecting all of them. Right click to property matrix
and do it this way here. You could change the
bright frames per second. A quick, I don't know. I think I did it before. Maybe my engine
crest, I'm not sure. But now we have that. Let's go back to the blueprint glass. Let's open it up again.
I go to blueprints. Enemies open up the night
we were working in. Let's go to the viewports. Here, you can see my night. Everything's looking
a lot better. Okay? In the viewport, you can see things visually. And inside of the event graph
is where you add the code, for example, at
movement and so on. For now, let's not focus here, let's go to the viewport
inside of here. We have to do it for
every single one of them. We have to assign the flip book. Let's go to the click up here. Open full blueprint editor. This view appears because you haven't worked in this
blueprint just yet. Let's open it up, click on
the sprite, assign the Or. If you just search for Orc, for example, and you can
select this one or idle. If you go to the viewport, you can see it is
looking correct. Here it is, Okay, awesome. You have to do it for
every single one of them. I'm just going to
show you this one and then I'm going to
do it on my own. The Orc Rogue, click on Sprite or go to the Rogue
and select the idol. Just make sure to select the idol for every
single one of them. I'm just going to do it
for the rest of them. Okay. This was the final one. In every single one of them, I have assigned
the character just like this and it's already
looking like a game. Awesome. Even though we haven't
done much yet, I'm just going to
click and compile on every single one of them. It's good practice. It wouldn't change much right now
to click and compile. But always nice to
remember just like that. And by the way, a good
thing to know as well, You can click on these three
dots and save and compile, and you can click on
this one, Unsuccessful. Only what this does is every
time I click on Compile, it automatically saves
here instead of, let's say I changed a
value here like this. Instead of compiling and then saving, you
can just compile. You can see the star, it
means it's not saved. If you click on compile, it automatically saves as well. This is really nice. I usually do this setting
this to unsuccessful only. You can also save
all if you wish to. Not really necessary right
now. Okay, here we are. Let's do another thing now. This capsule here is the
collision for this character. We don't really need
collision because the characters are just standing still in
the environment. What we can do is let's
close everything down. Let's open up the enemy
base for this capsule. Just so it's not this big. It's actually knowing
that it's this big and the character
is this small. Usually it fits the character. Instead of clicking on this capsule component and
changing the value here in the capsule height and the capsule radius to make it fit the
character like this. Instead of doing this for
every single character, remember I'm just going to click on this arrow to reset it. To default, remember we
have the enemy base, which is the parent class. Go to the viewport. I'm just going to click here
and try to set it to 12 by 12 like
this and compile. And now you can
see what it looks like in the night because it automatically now changes it for every single one of them. They have all this
setting applied. Let me just take a look and
this is what it looks like. This one we are using for when you click with the mouse
and damage the enemy. I'm going to make it
a bit larger so we can hit the enemy a lot easier. Maybe instead of 12 by 12, let's make it 16 by 16. Let's try this. We can
always make it larger if the hit box is too
small, 16 by 16. Looking nice for the
capsule component. I'm going to click on it. I'm actually going
to go down here in the Collision settings
and I'm going to say generate overlap events. No, no here for the collision, we need to add some
collision later. But for now let us just click
here and say no collision, and we can make it
custom later on. Go and compile and
save everything. Now every single one of
these blueprint classes, they have the collision
set to non as well. For the sprite, just
make sure we don't have any collision in the enemy base. Again, remember enemy base
sprites in the collision. I'm going to set n here, No collision and everything
is looking great. Also in the character
movement component, make sure that the gravity is
zero so we don't fall down. That max acceleration is zero. We can make the max
walk speed to zero. Everything is looking fine. I believe we don't really
need to change much. Let's compile here.
Let's save everything. And this was it for the enemies. You can always drag one of them. For example, the skeleton. You can write in
the Y to be zero. We bring it to the
front, and here it is. This is what it looks
like if you click on, remember is the game view. So you can click on to hide the icons and you can
see what it looks like. You can click on the player right click and
pilot the camera. You can click on F 11 here
to maximize the viewport. Remember 11 is if I click here, it's the immersive mode 11, we'll maximize the viewport. If you wish to change the
position of the camera, you can always click
here and change the location of the
camera to be centered. I can see the pivot point
here for the camera. You can change it to
be on the character. For example, you can
click on 11 to maximize. I can even make it
further down like this. 11 here is my character animated and everything
is looking great. I want to, however, click on my character
or my player camera. In the camera, I'm just
going to write 640 here. Instead, I'm just going
to zoom out a bit. I think it's a bit
too zoomed in. This was way too
zoomed in, I think. Let me actually just try to
right click and pile it. And click on 11. And this is what it looks like, looks a lot better than before. And I am happy with the results. Let me click on this button to go out of the camera again. I'm going to click here.
Delete this for now. Yeah, everything
is looking good. We have the enemies set up
now in blueprint classes. Now let's go ahead
and save everything. Let's move on to the next one.
20. 3.07 Applying the Player Camera as Default: What we need to do now before we continue is we need
to make sure that the player camera is looking at the game
when we play the game. Because you can see
when I click on play, it looks at the game from where I am right now
in the viewport. And it's not really using our
camera that we set up here. Let us go ahead and do that. Click on this BP player and
go ahead and delete it, because what you need to
do now is click up here. Instead, go to Basic and select this one
called a Player Start Start Component. Now if I drag
it down here to the front, you can see it has an arrow. I have to rotate it here. Clicking on for the
rotation tool and rotating it so that the
arrow points to the map. The players start is going to allow the player to
spawn here where I set it. Now what you need to do is just make sure inside
of the game mode, if you go into the game mode and you save everything inside of the game mode in the
class defaults make sure that the default P class, you change it from the
default point because we want to use the BP player to
spawn with as our player. The default point
class is BP player and compile and save
everything if you want to. You can also make sure
by clicking up here in the Project Settings,
Edit Project Settings, and going to the maps
and modes in here, make sure the default point
clause is BP player as well. It should be automatically
when you apply to the game mode as well as
inside of the world settings. Again, if you don't have
the world settings open, you can click on Window up here, open up the world settings, but inside of here
in the game mode, you can click down here on this arrow and you can see that the BP player is
the default clause. Again, all of this should be automatically applied when
you change it inside of here, Don't worry about it too much. But it's always
nice to know that it has to be correct here and it also has to be correct
in the project settings. Now if I click on Play, it is going to use
the BP player as the default on class to
spawn into the world. If I click on 11, this is what it looks like. What you can do is you can
always click on the players starts and you can change the X, Y, and Z. I can say
it's not really changing here because I think it's because I'm playing there. If I just move it down
and I click on Play, you can see it
changes the position. You can always try to
center it here, whatever. Because the enemy is going
to spawn maybe on this side. And I'm going to move it
bit more to the side. Let's click Play. It's
not really too important. I think this is fine for now. We're going to fix
it later as well, but this is good for me. Let's click on File
and save everything. And now every time
we click on Play, we are using this spawner
to spawn the camera. And we play from this view. Go ahead and save everything, and let's move on
to the next one.
21. 4.01 Creating the Enemy Spawn Point: What we can do now is we can start adding the spawning point for the enemy because now it's time to have the enemy
spawn into the world. To do this, let's create
a spawning point. The way we can create
a spawning point. Now you might think you could add another player
start and try to have this player starts
location to spawn the enemy. But this is only for
the player and it will get confused when
I click on play. Now it's actually
using this one, and when I click on play
again it's using this one. It keeps switching between
those and gets confused. Let's delete this second one now for the spawn
points instead, let's click on the blueprints. And let me right click
and make a new folder. Let's, let's call it spawn
points. Let's open it up. Let's right click and create a new blueprint class
as a spawn point. Let's just make a very
simple at this one called actor base or just
actor and click on it. Let's call this one
BP spa point base. Again, I usually make blueprint classes
because I like creating children blueprint classes
that we can use later on. If we need to change specific
value for all of them, we can do it inside the
main here the parents. But we might not need to create more than one Spain
point, I'm not sure. But it's always nice to create
a base, right click here. This is also the case when
you develop a larger game. You're not sure if you need
more than one Spain point. But it's always nice to create a parent one because you might regret it later if
you don't create one and you have to make
them all over again. Let's right click here and
make a child blueprint class. Let's call it EP
Enemy spa Point. Now I can click and drag
this into the world. Let's set the Y to zero. It is here in the front. You can spawn the enemy
wherever you want. For example, you can
spawn the enemy here. Whatever is not too
important right now, if I click on Play, the
enemy will spawn here. Okay, now we have
created the spawn point. Let's save everything for now. Let's click on this
enemy spawn point. Make sure that we don't need
to change any settings. We don't really
have much. You can see here in the components, we only have the icon we don't have that we can do inside of here because we
haven't added anything. We don't need to. I'm
only using this actor. Find the location
and rotation in the world so that we
can spawn the enemy. Okay, that was it
for the spawn point. And let's continue
on the next one.
22. 4.02 Spawn Actor of Class: The point of all of this now is we need to spawn the enemy. And how do we spawn
things into the world? In Unreal Engine, let's do that inside of
the Player Controller. So what I usually do in the Player Controller is I
spawn things into the world. If it is character, I need
to spawn if it is a weapon, I need to spawn if it is a
coin gold, I need to spa. It is all done inside
of the player control. Let's open it up and let's
go to the event graph. Because I want to program now. By the way, you can hold right click and navigate around here. Let me just select both of them. Hit Delete on my keyboard. And let's start here. When you start
doing programming, you basically need to think,
what do I need to do? Okay, I need to break it down. Okay, I need to
spawn an enemy here. This is what I want.
What do I need to do? I need to use the main function that is used to spawn things. I right click. If you don't
know what it's called, you can always for it,
for example, spawn. You can try to take
a look and see which one fits yours the best. It's not all of these casting, the functions stopped here, you can see it's called, these are the functions you can use. If you don't know
what it's called, just search for the word. For example, I need to spawn something. Just
searching for spawn. Actually this one spawn
actor from class, I'm going to click on it here. This is the function that is going to spawn things for us. Now in order to
run code inside of vulnerable engine,
you need an event. Without an event, you cannot
run code if you write click and you go down here
and search for events. If I can find it here. Event Dispatchers,
it's not up here. If I go up I can
actually this one, it's a event in the ad event. You can see these are the
icons for the events. And you have a lot of events you can use to start your code. For example, begin play
is the most simple one. If you click on it, you can see events are marked with red, functions are marked with blue. The red one here, Beginplay is simply saying this
is a simple event. What should happen when I
begin playing the game? If you click here
and you connect it. Now if you click on Play, it's going to run
this function here. Without an event, you cannot
run coding on real engine. We need to use this
one spawn actor instead of using a normal event. Let's right click and
make a custom event. Let's just make a custom event. The difference is with the custom event is you can
just give it a custom name. I'm just going to call it spawn M. This is
what we want to do. I'm going to connect it
here, and here we go. For this spawn function, we need to define what
do we need to spawn. For example, we need
to spawn the rogue, we need to spawn the
warrior, and so on. Now it really depends
on what level you are, because in Clicker
heroes for example, it really depends on my
what level you are in. In level one maybe you want to spawn the warrior and level two maybe you want to spawn the Ok Shaman and so on. So we can't really specify
which one we want to spawn instead of just specifying here what we want to spawn depends on the level. I'm going to click and
drag this pin into the function here and
we can decide later. Instead of calling it class, I'm going to call it enemy
that we want to spawn here. This is the variable we added. Really cool thing, this
spawn transform as well. We can drag it into here. But instead of
creating a variable, you can either
click on the event here and click on the plus
and create the variable. For example, I can click here on the variable type and I can select transform,
just like this one. And I can connect them together. I can do it like this, or if I just delete this one again, I can just click and
drag like we did before, drop it into the event, and it creates it for
me automatically. Very cool method to do it as I'm going to spawn the enemy. Now for the spawn transform, it really depends on where
this spawning point is. I'm just going to put both
of them into the event. When we use this event later, we can specify where the
spawning point is and we can also specify which
enemy we want to spawn. But for now we can't
really decide here. For the spawning, I'm
going to click here and say try to adjust location, but always spawn
to make sure that my enemy is going to
spawn here over here, it's always nice to have a variable of which
enemy you have spawned. I'm going to right click this one and promote
this to a variable. I'm going to call
this one spawn. Enemy. Okay, what we're simply doing is we're
spawning an enemy, and then we are storing this
information into a variable, which we can use later. Because this one is
really nice to use if we need to do something
with this spawned enemy, We have this data
inside of a variable. Okay. This is the
simple function, the spawn actor of class. You can see here if
I call this event later because you
can't run this code. So if I click on play, don't
expect the code to run, because in Unreal Engine, you have to specify in the engine when you
want to run this event. For example, I can
right click here and I can search for my spawn enemy. Event, spawn enemy. And you can see it here
and says call function. So I can click it and I can
call my code spawn enemy. I can call it here
whenever I call it, I can then run this code. If I just write the begin, Play just to show you begin, play is the simplest event.
I can connect it here. Whenever I begin
playing the game, it's going to call this event, which then goes to
run this code here. This is how it happens.
Let's say for example, I want to spawn the wizard. For now, let me take this one, instead of writing a value, let me take it and say I'm going to make a transform
myself just manually. We're not going to
do it like this, but I'm just going to
show you, for example, let's copy the location
of this spawning point. I'm going to say 170 by
zero by -120 Here in the location 1700 -120
I'm going to compile. Now when I click on play, you can see my enemy has spawned at this
certain location. It is the wizard
that has spawned this all functions or
this how we call events. You have to have an event. You run this code,
you tell the engine, run my spawn enemy events. And it's going to
run your events with the specified things you
have specified here, I want to spawn the wizard, for example, in this location. It's going to plug this
information into here, into here. And it's going to spawn the enemy and store
it into a variable. Now let's delete this.
We don't need it. I was just going to show you. Let's compile and
save everything. Now let's go to the game mode. We can always spawn it from
here, from the begin play. But just to make a
bit cleaner code, let's spawn the enemy
inside of the game mode. Now that we have this code
where we spawn the enemy, let's run the code
inside of the game mode. Because the game mode is
deciding the rules of the game, it's more clean to do
it inside of here. But it actually doesn't
matter in single player. If you spawn the enemy
from here or you spawn the enemy from here,
doesn't really matter. But just to make a cleaner code, let's do it in the game mode. I'm going to do it
in the begin Play. I'm just going to
select this one and delete it inside of here. Let's drag and search
for spawn enemy. You can see here
when you do this, you can't see anything. This is because now this
game mode doesn't realize what you have created inside of this other blueprint class. Remember, these are two
different blueprint classes. Now you actually need to go into something called
blueprint communication. Needs to communicate with
other blueprint class, because this game mode needs to use this from the
play controller. We need to use something called casting to communicate
with this other blueprint. And we're going to do
that in the next lesson.
23. 4.03 Blueprint Communication - Casting: Now we get into
blueprint communication. And now we need to
communicate with the player controller inside of the game mode to tell
the player controller, or here in the game mode, to use and call
this spawn enemy. To do this, let's down here, right click and say now what you need to think of is what do you need to
communicate with? I need to communicate with
the player controller. Let's search for
player controller. We need to get this function called get player controller. We're getting this
default layer controller from Unreal Engine. Now we need to say
here that we need to use this specific
controller that we made. We don't need to use this
default player controller. What we need to do is right
from here and say cast two. This is what casting is. You are telling the
engine that you want to use this custom
controller specifically you have to write
the name of it as to PC Dungeon Clicker. Go ahead and connect it. Now what we're doing here is we're taking the
default player controller, we're casting to this
PC dungeon clicker. So basically we're saying we
want to use things inside of our own custom player controller instead of this one from here. We can now call whatever we create inside of here,
this spawn enemy. Then for example, I can now drag from here and say spawn enemy. Now I can use it, remember you can't
just write click and say spawn enemy because
it's not going to show. It's only going to show if
you drag from here and say spawn enemy because
it is inside of here. And now you can actually use it. Now you're communicating
with this blueprint. But the problem with this
with casting is that you create hard references
in Unreal Engine. When you create a game and
you create a large game, you can imagine how much
you're using casting because you're
communicating with many blueprints at once. You have a lot of
these. Now this is a problem because it
creates hard references. And what hard references is, is you need to load
those references whenever you start the
game. Sometimes you see if you open an old game
and it is loading for like 15 seconds before it
shows you the main menu. This is because
it's loading all of the hard references before it can even start.
This is really bad. I'm not saying that you
shouldn't use casting anywhere, but use it like with ease,
don't use it everywhere. Use it wherever you find it. Good to use it will get there. With experience, you will know when you want
to use casting. And why not try to avoid
casting as much as possible. So let me just delete
this casting now, or actually just let it
be here. Let me just Alt and disconnect this. Here. Let me move
it down for now. Now instead of using casting, let's use something called
blueprint interfaces. Let's move on to
the next lesson and see what blueprint
interfaces are.
24. 4.04 Blueprint Communication - Interfaces: All right, let's get into
blueprint interfaces. Now, this subject is
difficult for many beginners, but I'll try to explain as usual the best that I can
to explain this to you. To avoid high references
with the casting, let's use blueprint interfaces. First, let's right click here, Make a new folder
called interfaces. Let's stay organized
inside of here. Let's right click now. Inside of blueprint, you see something called a
blueprint interface. Let's go ahead and create it. Usually I call it as a beginning people call it BPI for blueprint interface.
Let's actually do that. Let's call it BPI,
blueprint interface. Let's call this one. The name of this one is whatever you are trying
to reference to, whatever you're trying
to communicate with. In this case, I'm trying to use a function from my
player controller. I'm going to call this one PI controller. This
is what I want to reference to. Let's open it up. Inside of a blueprint interface, you can see you have a viewport. You can't really do anything. It says read only, you can't drag or anything here. The only thing you can do is create functions
here to the side. Let's click on the
first function here. Let me click on
two to rename it. Let me call this one, Get play control reference. Get player control reference. This is what I'm trying to do. I'm trying to get
the reference for the player controller so that I can use whatever is in it. Just like what we
did with casting, I can use this function inside of it here. Let's go back to the interface. Get player controller
reference inside of here. I want to make an
output variable here. Now the type of variable is whatever you are trying
to reference to. I'm trying to reference
to my player controller. I need to search
for it down here, Search for PC controller, we called it PC actually,
net Player controller. We call PC Dung Clicker. Let's click on it.
Let's rename this to Play Controller
just like this. Let's compile and we are
all done inside of here. The only thing we
created is this get player controller
reference function. And we added a variable to the output here called
player controller. We're going to use this to define this player
controller here. Now, now that we have created
the blueprint interface, let's now go into the Player controller and
inside of the class settings, we need to add this
interface over here. Let's click on in
the class settings, let's search for the BPI and let's add the
Player controller. Now notice when you add the
Player controller here in the interface that actually you get a bar here
called interfaces. And you can see this get
player controller reference function that you just created, the list, double click on it. And here it is here,
you can edit it. What you need to do
inside of here is simply just drag and say self do it here. Now we have a self reference. What a self reference
means, basically, is that we're defining this
player control variable. Because I click
Alt and click here to disconnect it. If
we didn't do this, know what this variable
is, It's empty, doesn't have any information, but doesn't really know it's this player controller
we are in right now. This is what self
reference means. If we plug this in, we have given a value
to this variable. We're basically telling
this variable that the player controller
we are talking about is self meaning. Whatever blueprint
we are in right now, this is a self reference. Now let's continue so it
doesn't get confusing. And I'll explain the whole
process when we finish. Now that we have done
this, let's close it. Let's open up or the game mode. Now, just like before, let's say get player controller and get the default
player controller. Now instead of casting, we can now drag and say
controller reference. Now you can see this comes
from the blueprint interface. It is also a blueprint
interface function. When you see this message at
the end, let's click on it. This is also what
this icon means. It means it comes from
a blueprint interface. Let's go ahead and connect it. Now from here,
let's drag and say spawn enemy, just like before. And now we can call
whatever is inside it. Now you see when I go to
the player controller now. And if I add a new
variable called, for example, enemy we save. Pile. So now inside
of the game mode, I can direct from here
and say kill enemy. And now you can see, I can see this variable I just created. Whatever I create
inside of here, I can communicate now with the player controller and
use everything from it. Okay, let me just explain the whole process before
I end this video. If you have already
understood it, you can go to the next lesson. I'm just going to
delete this one. So I'm just going to
explain the whole process. So it's easy to understand. To begin with, what we did is we created this blueprint
interface by right clicking. And in the blueprint we created
the blueprint interface. Now inside of this interface, we just created a function called get player
controller reference. Because we want to get the
player controllers reference. Whatever you need
to reference to, you need to create a variable
and set the variable type. Here is whatever you are
trying to reference to. We are trying to reference to this player controller
called PC dungeon Clicker. This is why over here
in the variable type, I set it to PC dungeon clicker. Basically just
search for it here, PC dungeon Clicker, and
you find it like this. Okay, just give it a name. I just called it
Player Controller. And remember to compile. If you don't compile, it
will not appear over here. So remember to compile,
save everything. Now you need to add this
blueprint interface into the player controller, because this is what
you're trying to reference to in here. We went into the cloud settings, we added the
blueprint interface. When you do this, the function will appear here to the left. You open up this
function inside of here. We basically made
a self reference because if you disconnect this and you compile and you try in the game
mode to do this here, if you click on play,
I'm not sure if it will give me an
error right now. It will because we
are running this in the begin play and
it will give me an era. It will say access non. Trying to read the property, get player controller reference inside of the spawn enemy. If I click on it here,
click on this one. Let me just minimize
it to show you if I roll over here and I
click on this spawn enemy. The era is here. It says Access. Trying to read the property, get player controller reference. It says Access non, meaning I don't have any information from what
you're trying to give me. I'm trying to give it this Player controller
as a reference. But it says none. It means there is no
information here whatsoever. And I can't do anything with this is because
in the player control, in the blueprint interfaces, we did not connect this self. Because if it is empty, the engine doesn't
really know what this play controller
is. We have to tell it. The player controller I'm
talking about is me here. The player controller.
This blueprint class I'm already in right now. Now that we have defined
it in the game mode, we can now call this
blueprint interface. But first we have to get the default player
controller from this, this get play
controller reference. But from the blueprint interface from here we can now
access everything from it. Because remember in
the play controller we made this self
reference here. It knows what the
play controller is that we're talking about. Okay, I know it's a bit
confusing for beginners, but trust me, very,
very simple concept. If you just practice
with it 23 times, try to re, watch the
end of the video. Maybe just try to
get the grasp of it. We are going to do this at least five times
in this course, so you will also
see other examples, not only the play controller, but we will see other
examples as well. I'm also going to let you
do it first before I do it, so you can get some
practice here as well. But for now we're finished. We have connected
this. However, you can see here we need
the spawn location. We need to spawn the enemy
at this location here. Instead of making
a static value, like dragging and saying transform and making a
static value for example, we can just write a value here. We want to know where
this spawn point is. We need to spawn this enemy. Depending on where
the spawn point is, this is what we're going
to do in the next lesson.
25. 4.05 Getting the Spawn Point Values: Here I have opened
the project once again and now it's
again telling me that the Nenite is enabled
but cannot render because the project has
Nani disabled in an I. And I remember we disabled Nanite in the project
settings now instead of writing anite here in the console 2047 because
we already did it. Every time, you're
going to close the project and
open it up again, it's going to display
this message. Instead, what I want you
to do is I want you to go into your project folder and you can find it in documents. And going into the
Unreal Projects, this is where your Unreal
Engine projects are saved. Then going into the
Dungeon Clicker, I want you to open the config and opening this one
called Default Engine I. Inside of here, what I want
you to find is I want you to find one here, right? Project enabled equals
false down here. I'm going to write
my custom code here instead of the console
command. Let's write it here. Nt equals zero. This is what I want you
to write, R equals zero. Let's save it. By the way, I'm using Notepad plus plus. You can use your
normal text editor. Really matter what you use just writing R n equals
zero. Let's close it. Let's close this
project as well. Let me try again
to run my project and see if the message is
gone. And it should be gone. It shouldn't be
there. There we go. The message is not going to appear anymore. Okay, awesome. Instead of here, what
we want to do now is we want to get the value
of the spawn point. Because remember where
we left off in the mode, we made the blueprint interface. We called this spawn
enemy function or event rather we called this event is inside of
the player controller. This one. By the way, let me increase again my UI scale because every
time I close the engine, I actually have to
increase it here to 1.25 so you can see better. I hope I don't forget. Let's open up again. Here, and here you see the spawn enemy. This is the event we
called from the game mode. Now what we need to
do is we need to tell it where do we want
to spawn this enemy. This is the spawn transform.
How do we do this? We need to get where
this is in the world. Now there is a function
you need to use and it is called actor of class. Actor of class is
a function that gets something that is already
spawned into the world. For example, there is this
enemy spawpoint we can get. If you open up this
get actor of class, if you click here and
search for spawn, then you can see you can
get BP enemy spawpoint. Or you can get the BP
spawpoint base and so on. So you can get
these blueprints If you get a blueprint which is
not spawned, for example, let's say I call BP night, this one the night
that we created. Let's say I say get actor of class night and I play the game. It's going to give you an error. This is because the night
is pond in the level. These are all the things
we have in our level. The players start the
post process volume, the tile map, and
the enemy spawpoint. What we can do is we can
search for enemy spa point. This one enemy spa point. We're getting this actor. What can we do with this one? Let's actually get it
inside of the begin play. Before we do all of this here, let me drag this way
and I'm going to place this one down here like this
and I'm going to connect it. What we want to do here is
let's just right click, promote this to a variable. Let's call it enemy spawn point. Now we have it stored in a variable, and
let's connect it. Now we can use this
variable here. Let's take this variable, drag it into here,
and click on Get. Or you can hold control
and drag it and drop it. It will get it automatically. You can also hold Alt, hold alt and drag. And it will set this variable instead of just
drag and click get. And set either hold
control and drag, or hold alt and drag. Now we have this
enemy spin point. And let's say now again, if you don't know what
the function is called, just search for the word I
want to get the transform. You either get the
location of this variable, of this actor, get
actor location. You can use this, you
can direct from here, you can see you can't
really connect them. But it's going to convert this for you on real engine is
going to convert this for you. Now it's not fully
correct like this. You can direct from
here and say transform. And when you make transform, you break this transform down. Because if you don't know
what a transform is, this is what a transform is. You can actually see it
here in the details panel. When you click on something, you see the location, rotation, and scale of an item. This is the transform. The transform can be broken down into the location,
rotation, and scale. This orange color
is the transform. You can break it down like this. And you can connect the
Acta location into here. And it will work just fine. However, just to make it shorter, you can
actually delete this. And you can drag here and
search for transform, and you can get the
Acta transform as well. Now sometimes you need
to be careful because it's getting both the location, the rotation, and the scale, and it's affecting the
enemy with these values. If you click on this object, it's getting the location which is fine. I want to spawn here. It's also getting the rotation which is 000, which is fine. Imagine if this act
had this rotation, let's say it had this
random rotation. This is going to be
applied to your character. Be careful when you use
get actor transform. Sometimes you have
a rotation set like this for this asset which you don't want to be
applied for your character. In this case, you should
get a location by itself. You can use rotation by
itself if you don't want the rotation right
from here and say make transform and you can
use the location instead. And then you can just leave
the rotation to be 000. But in our case the scale
is one which is fine. The character scale is also one. The rotation is
000, which is fine. And this is the
location which we want using the get act to
transform is perfectly fine, in this case here.
Now we got it. Let's just compile and
let's just give it an enemer, for example, the Orc. Let's see if the Orc
spawns actually, that's over here, the Fc play. You can see that Orc
is actually spawning. Awesome. It is working. We can now spawn here. Let's for example choose
the skeleton mag. If I click on play, I think actually instead
of clicking Play and always minimizing like
this to see if it works, I like to play here. Let's see playing as
a new editor window, it pops up for me and it popped
up on my second monitor. But basically this is here, this is the skeleton mate, and it is working just fine. Okay, the spawning is working. Now, what we need to define, which enemy do we
want to spawn Now, this one is a bit more complex
because as I said before, every single level in the
clicker game has its own enemy. Level one has, for example, this guy here, level
two has this guy. We have to define which
level has which enemy. We can't really just specify
a specific enemy here. To do this, we have to
learn a couple of things. Structures, data,
tables, libraries. But it will be a lot of fun and it can also be applied
to your future games. Keep yourself focused on
the next couple of lessons. Very, very important
stuff coming up. Let's move on to the next one.
26. 4.06 Introduction to Structures: All right, welcome.
And now we are going to have an
introduction to structures. Now if you already know
what a structure is, you can skip to the next lesson. And if you don't know
what a structure is, let's get started here. Let's go over to the enemies. Now for the enemies, let's go to the enemy base. Remember, in the enemy base, if I create something, if I create a variable
and say enemy health, for example, the variable
type we set is a float. Because a float is
a numeric value with a decimal
place if I compile, you can see it
here to the right. When I click on the
variable enemy health. And I can set it
to, for example, 25.6 whatever this is,
the enemy's health. Now I can also make a new one. Let's for example
call it enemy type. The type of enemy we
have to deal with this one. We can just set
it to a name, whatever. We can have a lot of variables. We can have the enemy's
health, the enemy type, the enemy's name, the
enemy's idle animation, the enemy's death animation. You can see we can have a
lot of variables down here for the enemy that
defines this enemy. However, to keep it more
clean, we use structures. Instead of filling this
whole thing with variables, let's go over and try
to use structures. Let me delete this one. And
delete this one as well. Compile, let me minimize this. Let's go over to the
blueprints folder. Right click, and
make a new folder. Let's call this one Structures. Let's go over here, right click, Go to blueprint and you see
this one called a structure. Go ahead and created,
I'm going to call it ST or structure. Let's call it enemy info. This structure contains data about this enemy.
Let's open it up. Okay, here we are
inside of a structure. The only thing we do is just create variables inside of here. Here in the enemy info, we can specify the name of the enemy, we can specify the
health of the enemy, we can specify what level
it spawns at, and so on. We can make a lot
of variables that defines this enemy here. Instead of having all of
the variables down here, we can actually have
it here instead. And it is a lot better
to use like this, it's more organized now. This is actually just what a variable or what a
structure is and you can see the default values or the variables
you have created. You can see them over here. Very simple. This is all data structure is hold some variables
that you can use. In this case we are defining the enemy's data,
the enemy info. Let's jump over to
the next lesson and fill out the enemy info.
27. 4.07 Level Info & Enemy Info Structures: All right, so for
the enemy info, let's define some variables that we will be using for enemies. The first one is the
name of the enemy. For this one I'm going
to set it to a string. Now if you don't
know the difference between a string and a text, if you select a string and you click on Save and you go
to the default values, you can see that a string is
basically a line of text. So we can write the
name of the enemy. But a text is also a line of text where you can
write the name of the enemy. So what
is the difference? The difference is that a text is localizable and you can also see that when you hold
the mouse over it, it says a localizable
text string. Localization means you
can translate this to different languages if
you want your game to be in German or you want
your game to be in Chinese, Japanese, in Russian, whatever. You can translate
your game if you have your dialogue or
your character name made with a text variable. Now if the character's name is made with a string variable, it cannot be translated. Maybe you'd say, why don't
we just use text like for everything since we can translate it and
everything will be fine. This is because uses more
memory than a string. We use string if you don't really need to localize
whatever you are doing. I don't need to translate
the character's name. I'll just keep it as a string. I don't want to translate
my game either. If you want to translate it, for example, if your
character name is Skeleton. Skeleton can be translated
to many languages. If you want to translate that, you have to select text instead. Just keep that in mind. Whatever you are doing as text, do you want to translate it to another language
or do you want to keep it in the same language that you're coding this game in? I'm just going to pick string. I don't want to
translate anything. What we want to also
add is the class. The enemy class is P M base. So go ahead and search for PPN M base and select
the class reference. Now if you don't really know
what a class reference is, is if you go and open the
game mode, once again, this is what we have spawned from is an
actor class reference. You can see that if you
hover your mouse over it. So this is the class reference, we need that so we can define the enemies class
reference and we can plug this
information into here. The next thing we need
is the enemy type. What type of enemy
are we dealing with? Is it a normal
enemy? Is it a boss? We can add a bus
mechanic to the game. Instead of just having
everyone as normal enemies, we can have a bus enemy as well. Let's make an enemy type. Now for the enemy type, I need to use something
called an enumerator, which we don't know
what is right now. Let's just leave it
like this for now, and I can teach you in the
next lesson. Let's continue. For now, let's make
the enemy health. And this one is simply a float. And a float again is a
number with a decimal place. Let's click on the plus again. And we want the idle animation. Idle animation for
this character. This is simply a flip book. Remember, a flip book is an animated version of
this character here, choosing the paper flip book. Let's make a new one. Again,
we want the hit animation. It's again a flip book. Let's add a new one. We want to the death animation as well. This is a flip book. Okay, This is all the data
that we need for the enemy. And we're actually
finished here. Now before we finish, let's also do the other
structure called the level info. If I go to the structure and
I'll right click and I make a new structure in the
blueprint at a new structure. Let's call this one Level Info. Okay, let's open up
this level info. Now what I needed to
do in the level info, we need to basically define which enemy spawns
at which level. Basic here we need the level
which is just a number. It's an integer, now
it is not a float, it is not a number
with a decimal place. Because the level is
level one, level two, level three, we don't really
need a decimal place here. Instead, you can use
an integer which is a number without a decimal
place, as you can see here. Using an integer as the level
and then make a new one. And we need the enemy's name. The enemy name is
again a string. At what level or what enemy
does spawn at what level, we have to write the level. For example, level one is
the level two is the orcam, level three is the
warrior, and so on. We have to define that later on. Now we have the
structure for it. We have the structure
for the level info. We have the structure
for the enemy info. Now in the next lesson,
let's learn something about enumeration so we can finish
this enemy type here.
28. 4.08 Creating the Enemy Type Enum: All right, so let's take
a look at enumerations. Because here in the structure. So if I go back to structures
and open up the enemy info, we made this one
called the Enemy type. We need to define what it is and we need to create
an enumeration. Now we could just click here for the enemy type and do a string. Now inside of here, we can
define if this enemy is a normal enemy or if this
enemy is a enemy in the game. I want to have enemies which are normal and enemies
which are bosses. Okay? Instead of doing a
string and writing it here, better to create an enumeration.
Let's see what it is. Let's go to Blueprints. Right click, make a new
folder, call it Oms. Let's open it up here. Let's right click
go to Blueprints. And you have this one called an enumeration. Go
ahead and click on it. Let's call it enemy
type. Let's open it up. O Enumeration, very simple, is just a list of anything
you want to make. It can be a list of groceries,
for example, tomatoes, for example, tomatoes,
cola, ketch up, whatever. It can be a list of anything
adding a list item and you can write whatever
inside of here. It can also be a list of weapons you're making a
first person shooter. It can be AK 47, it can be an 41, it can be a Deagle
and whatever you want to make an enumeration is
simply just a list of items. In this case, I want
to make a list of the enemy or enemy
type for our enemies. We have normal enemies If I click here again and
we have boss enemies, you can also create other types if you
have a larger game, if you already have your
idea for your game. For example, you can have like legendary enemies,
loops, legendary. You can also have epic
enemies and so on. So you can have more
enemies, but for me, I'm just having
normal enemies and boss enemies we can save. Now let's close this list. Now here I can search
for it in the type. If I click it for
the enemy type, search for enemy type, this is my enumeration and I
can go ahead and click on it and save. Now we have
this enemy type, and if you click on
the default values, you can see here it's better
than a string because now you have a list
you can select from, which is very cool. It is a lot better than typing out the thing all the time. We can now select it from the list if it's a boss
or if it's a normal one. Okay, we don't really need to define anything
inside of here, because for every single enemy, they will all have their
own set of information. For all of these,
we don't need to focus about the default
values for now. Go ahead and save everything. And that was it for
the enumerations. Let's move on to
the next lesson.
29. 4.09 Introduction to Data Tables: All right, so
before we continue, I want to introduce to
you the data tables. Now that we have created our structures, we also need
to create data tables. If I go to the
blueprints folder, I right click make a new folder, and I call this one data Tables. I click here, right click. Now the data tables is
not in the blueprints. It is actually down here in the miscellaneous and you can find
it over here, data table. You click on it and you select which structure
you're talking about. I just want to make
one for my enemy info, we also need to make
one for the level info. But let's just make one
for the enemy info. For now, click on.
Okay, let's call it, for example, DT my
info data table. My info. And let's open it up. Okay, so what is a data table? A data table is the one that actually defines
every single enemy. For example, the idle animation, the hit animation, so on. So we created a structure, but every single enemy has its own values of these
variables in the data table. I can click on D
here in the row. You can see this is
the new row here. And you can even change the name for the row, for example, the row name, you
can just call it one or whatever you want to. For example, for the
first character, if I go to assets characters, the first one is the night. What I can do, for
example, is I can write select the class
of the night here. And I can select which type
of enemy is the night. It's a normal enemy. How much he does it have? Let's say it has 100 health. Now I have to select the
Edlin Imation for it. I have to select the
Hid animation for it, and I also have to select
the death animation for it. Now I have all of
this information and I can click on
the plus again. For the next one I want to, for example, define my Or. I can write this
guy is called Orc. It is the BP Or class. For example, a boss, it has 500 health and these are all the animations
for it and so on. So every single enemy has its own values and you can use those now to
make it a lot faster. Instead of doing
it in the engine, we can do it inside
of Google Sheets. Inside of a Google sheet, we can do it a lot faster. And also people who are not game developers can
also work there, for example, game designers. Let's go over to the
next lesson and take a look at how we can do
it in Google Sheets.
30. 4.10 Level Info & Enemy Info Data Tables: All right, let's go ahead and open up Google
inside of Google, just inside of your drive. And you can find it
over here in drive. Just go into your drive, right click anywhere, make
a new folds or whatever. But create a Google Sheets
here and create one. I'm just going to call this
one lit table or whatever. You can call it
whatever you want. Okay, here I like to click on Control to select everything. Just drag the columns down here the way I have more space
to work with and control a. Select everything and make it another font I
can click on here, horizontal line, middle,
this one and this one. I just like to
start with this and selecting the top part
and clicking on Bold. Now I are ready to
use my document. Now this is all optional. You don't really need
to do all of this. What I need to do here first
is I need to write ID. We need an ID because
in Unreal engine, you have to have an ID. You cannot really, this
is the ID, the Ron name, You can't really use this Google sheet. If
you don't have an ID. This is necessary. We need to write all the variables
for our structure. If I go back and I
open up my enemy info, this is what I need to write. I need to write the name, enemy type. Let's go back here. Enemy type, you have to write
it specifically like this. You can't write it differently. You have to write
it specifically as how you wrote
it. Inside of here. Idle, hit he. This is wrong health idle
and the last one is death. Okay. Now we have this. Now we can define the
information down here. The first one I have, I just thought this in my mind. The first one I want to
write here is the Or. The second one is the rogue. Now, you can have these enemies in any sequence you wish to. You don't have to have
the sequence as me, but I want to have
them like this or Sam, we have the Wizard. Then we have the Skeleton. Then we have the Skeleton, Roe, Skeleton Warrior like
this, and Skeleton Mag. Then we have the
Roe and the Night. We have 11 characters
are all here. You don't have to have it
in this same sequence. But I just thought in my mind
this would be an sequence, maybe for the ID. I just copy paste this here like this because
not really important. The ID is simply it needs
to be there for it to work. We have to just
copy paste whatever the name is for the class. We have to define
what the class is. Now how do we get this
enemy base class? Because we have to,
you click on that. Again, we have to
define this class here. What you can do is use this enemy info data
table inside of here. Just create a new row here. And what you can do
is you can click, the first one is the Orc. For me I can select the Orc, I can write, click here and
write copy. Or click Copy. Now I can open up
my data table and click control V on my
keyboard to paste. And here we have it. I'm just going to make it a bit larger so you can see like this. So now we have it
inside of here. Now what you can do is the
next one is the Or Roe. I can select the Roe again, right click copy or
what you can do is short cut is holding shift and right click this will copy it. Then I can paste it
here, just like that. Or what you can do is you
can also just copy this one. Paste it down here
and change this. Or to or Shaman for this one also remember to
change here or Shaman, you can do it both ways. Now, it's a lot faster for me to just select Aria, for example, hold shift and right click to copy control V to paste here. And do it for the wizard as
well, like this and so on. I'm just going to
do it for those. You can do all of this
yourself as practice. Now for the enemy type, we either have normal
or bus enemies. This one is normal and I'm just going to copy paste this here. And I think the wizard, we can make a boss like this. They can select which one are normal enemies and boss
enemies give them the health. For the health, I'd
like to just make a formula writing,
for example, equal. Let's start with
100 for this one. Actually, just write
100 for this one. We don't need a formula
for the first one, but for the second one equals this one, you can click here. Multiplied by 1.2 It's going to automatically
calculate this. And I can click on
this and drag it down all the way down
to the final one. I can select it
up here and click on this button to remove
the decimal places. Just like this, you can
also increase the health. You can multiply it
by 1.5 for example, you can drag down here we have a lot more
health, just like this. For example, for the
animation just like before, for the Adline machine, you can select the
outline machine here. Or let's actually do it down here instead,
for the Adline. Let's see, the
first one was the, if I close this and
I find the one, you can right click and
copy the reference. This copy reference, I go back and I click control
V and I paste it here. For these ones,
maybe you can make them a bit larger like this. Here it is. Now for the
hit animation again, I can right click my
hit and copy reference. I can paste it here
for the death, I can right click
copy reference. Then I can paste it here. Now I'm going to show
it to you also here. And I'll do all of
this on my own. Here, Rogue, I can
click copy references. Right click the, Hit
one, paste it here. And right click the Rogue. Copy reference and paste
it on the final one. This is how you add
all of this and again, or the class go over to the data table and
copy the class. Or you can basically just change this part
here to the name of the character and
you can define if it is a normal or a boss enemy. All right, so here I have
finished my data table. All the information
is here, down here. I just like to give it a name. Let's call it DT me info. Let's make a new
data table as well. I click on the plus down
here on the sheets, and I make a new data table. Actually, let's just
delete this one. Let me just duplicate
it so I don't have to format it again
with the font and so on. Right click, this
one duplicated and let's one DT level info. For this, I'm going
to delete everything, control a hit delete. For this one we need the ID, we also need the level. Remember, you can
always go back to your structure and open
up the level info. We need the level
and the enemy name. We open it up here, We need
the level and the enemy name. I'm just going to
make it smaller here, don't need all of this space. And making it smaller this
way as well for the ID. Now I'm just going to copy
paste the levels here. Level 1234, we have 11 enemies. I'm just going to click and
drag this down until 11. I'm just going to
copy paste this here for the enemy name. We can basically go
to the enemy info, copy all of this and we
can paste it here as well. We have to find at level one the span at level
two, the roll spawn. When the E spawns, we have to find
the rogues health, the bust enemy type, the Adle animation, and
all of this information. Here we are using this to choose what enemy
to spawn at one level. When the enemy spawns, we have the information about this enemy
which we can use. Go ahead and just autosave
can't really save here. Let's go ahead and
click on Download. And go and download
it as a CSV file, download enemy info and go
to the level info as well. Click on file, download
it as a CSV file. Now when you open up your downloads folder,
here they are. I'm going to rename them, It's only called T Level Info and also renaming this
one T Enemy Info. Before we do this, just make
sure inside of the engine, if I go back and I
close all of this, make sure in the
data tables you have the enemy info and it is empty. I'm going to delete
this one. Click save. I also need to make one for
the level info. Right click. Go to miscellaneous data table, select the level info, click okay and call
it T level Info. I have those, and what
you need to do is click and drag both of them
into here and drop them, and it should import
them successfully. Now if you have made an era in one of the
names, for example, if you have made an era in the enemy name
here, for example, let's say you wrote
enemy name without an E. It will tell you that there is an
era in your data table. And don't worry, you can
basically correct it here, download it again, and simply click and
drag it into here. Now when you open up the
enemy info data table, you have all of the information about every single character, how much health they have, the enemy type, and all of
their animations here as well.
31. 4.11 Introduction to Libraries: All right, now we have
finished the data tables. And let's go ahead and
take a look at libraries. This is the final step before we finish everything up
and spawn the enemy. So let's right look now
and make a new folder. Let's call this one libraries. If I can spell libraries
again just like this, let's go into this folder now. Let's right click
and go to Blueprint. And you see this one called a blueprint function library and a blueprint macro library. Now we are working
with functions. Let's just create a
blueprint function library. And I'm going to call
it BP function library, because I usually just
have one in my game. So I'm just going to call
it function library. Now, open it up inside
of this library. You can see it's basically, as the name says, it
is a function library. So you can create a lot of
functions inside of here. The good thing about
a function library is the functions
you create here. You can use it globally
across blueprints. Let's just create one for fun. For example, let's
call, for example, get health test function. We're not going to use it, but if I click Compile. Now if I minimize this and I
open up another blueprint, for example, let's
open up the game mode. Inside of here, I can write, click and say Get Health. Here you can see it is
from my function library. We don't have to make blueprint
interfaces and whatever. We can just write,
click Get Health, we can use this function. Now, you might be tempted to create all of your
functions inside of here. Because maybe you're thinking, why am I even creating blueprint interfaces
and calling them? Why don't I just
create them inside of a function library? This is because game
will get slower. As I've researched,
your game will get slower if your function
library is too large. Use it whenever it makes sense. Don't just add functions here, because if this is too large, your game is also going
to be a bit slower. Just use it whenever
it makes sense. What I usually do, I
usually use it whenever I make data tables because
I need to use this in, in a lot of blueprints. Maybe you can think
of it as like this. When you have a function
that you need to use in almost every
single blueprint. For example, getting
the enemies info here. Then it's better to
create it inside of a function library so you can easily access it in
every blueprint. I usually use it whenever I create structures
and data tables, and I need to get
that information, I create that inside
of function libraries. Let's go ahead and delete this. Let's compile and
save everything. And now we are ready to
move on to the next lesson.
32. 4.12 Creating the Library Functions: Let's go ahead and create
the function libraries. Let's click on Ad and create
a function inside of here. The first one we are going to create is for the enemy info. For this one I'm going to say actually before I forget again, let me just click up
here in the tools debug which is reflector,
make it Lodgust. We can see better just
like this inside of here. What I'm going to call
it, I'm going to call it get enemy info. And I'm going to make
a new one as well, new function called get level
info. We need these two. Let's start with the first one. What we need to do is right
click and say get a table. You see this one down here. Get data table row. This is the function
we're trying to use. We're trying to get a data table row from a name here so that we
can use the information. Let's go ahead and create
it and it will be a lot better to understand
once we finish. Now let's see data table, we're talking about this one, in this case it's
the enemy info. Let's select the NM
info for this row name. Now before we plug it into here, I usually like to right click and say, actually let's
add a string first here. Adding an input and string.
Go ahead and do that. Here we need an input
of the enemy name. Because if you go back
to your data table, this one, these are
the enemy names. We need an input
of an enemy name. From that name, it's going to extract this information,
this row here. Let's go back from here. What I like to do
before I plug it in is I like to use the replace function. With a
replace function, what that does is
here in the from, you're going to write
one space like this. You have one small space here, as you can see in the two. You don't do anything. You have one space up here
and you have nothing here. What that does is it takes this name here
if you have a space, because as you can
see in the row name, you can't have a space. Nal engine will not
accept that you have a space in the row name.
And this is what it is. This is the row name. You have
to extract information if you give it an enemy name and
the enemy name has a space later, I'm going to show
you how to do that later. If it has a space,
it's not going to read, it's going to buck. What I like to do
is the enemy name, I'd like to remove the space
before doing anything. Then I can just drag
this into here and it will convert this string
into a name variable. We can connect this,
then we can drag here and say return
because we need a return node for this function. For the return node, it will
output this enemy info data. Let's call this one enemy
info, and let's compile. And now we are finished
with this one. This is what it looks like.
We get the enemy name, then we extract this information. For example, let's say the
enemy name is Skeleton Rogue, going to remove the space, so it actually can
read from here. Then it's going to get all
of this information for you and it's going to plug it
out here so you can use it. Let's do that for the
level info as well. Now for the level info, you can do it
yourself if you wish to have some practice else. Let's do it together if
you need more practice. Okay, here, let's right click, get a table row just
for the level info. If you go back to the level
info, the level info is numbers. We need a number
instead of a string. Over here I'm going to say plus. And let's take an integer here. For the integer,
let's say a level. Let's go ahead and connect it. Now for this one, we
don't really need to do replacing all of this
because it's just a number. And we can just drag
this into the name. Now, it doesn't convert
it automatically for us, this is because it only
converts the string. Let's do two string and
go ahead and select this. And then go ahead and drag it in and it will
convert it for you, again, make a return node. Before we do anything,
you can see it's gray. This is because we haven't
selected anything here. Let's select the level info, and let's plug it into here. And let's call it level info. Let's compile and
save everything. Now if we try to use
them in the game mode, for example, let's
delete get health. This was an old one for the enemy info we can
write get enemy info. And here you can see it. Now we have this
function that we can use and we have
the enemy info. Basically you can drag
from here and say break. You're breaking this
structure into multiple pins, which you can see here. These are all the variables you created inside of
your structure here. These are all the
variables you created now, it can now be used by you. You can have the
name of the enemy, the class, the enemy type, the health of the
enemy, and so on. Here basically you are
getting information, you don't need these
execution pins. As you can see, some
of the functions are green. They are not blue. They're green. This is because they're basically
getting information. This one is getting the
actors transformation. If you just click here, you can see find nearest Acta. It's not really setting
any information, it's just getting
information for you. When you get information, you don't need these
execution pins. Let's go back to the
function library. Let's click on the enemy info, set this one to pure. Let's click on the level info
as well, set it to pure. Now let's go back,
and here you can see now we turned it into
a green function. We're basically just
getting information. We're getting the enemy info and it needs the enemy's name. Then when we plug in the
enemy's name, for example, skeleton mage, as you can see, I write a space here. I can just write it normally, Skeleton Mage inside of here. It's going to remove the space automatically as we
have added a replace. If you just write it like this without a space, it
doesn't really matter. It doesn't find any spaces. It's just going to continue. It is a preference,
but I'd like to write the names fully
like this normally. Then you can write from here, write break, and now you have
this enemies information. This is how you use it. The same thing with
the level info. If you say get level info, it is you plug in a
level, for example, level three, you break
this information. And now you know from level three you know which
enemy is going to spawn. Because in your data
table at level three, you have told it that the
auctoman should spawn. Now you know the
auctoman should spawn. And you can basically
plug it into here, now you can see how you
can connect them together. But for now, let's delete this. Let's compile and let's
continue with the next lesson.
33. 4.13 Adding the Enemy Names: All right, now we need
to add the enemy names, because we need those names
to extract information from the enemy info data table inside of the libraries
we just made here. But we need to plug
in the enemy names, we need to add the
names for each enemy. The way we do this
is if we go back to the enemies and here
in the enemy base. Let's open that up. Open the full blueprint
editor inside of here. Let's create a variable
called name for example, or you can call it enemy
name. That's fine. I'm going to make it a
string. Go ahead and compile. And remember, when you create a variable inside
of the enemy base, these are all children
of the enemy base. When you create a
variable inside of here, they will also be
created for all of them. Let's open the first one. Open up the full
blueprint editor and inside of the
class defaults. Let's see here class defaults. If we scroll down here, you can see the name
variable we created. Now you can give this
character a name. For example, let's
call this one night. Now let's open the next one. It is the Orc. Instead of opening the full
blueprint editor, you can actually also do it down here showing you
the details panel. This one is the Orc, the
next one is the Rogue, the next one is the Shaman, and then we have the warrior. Then we have the rogue spell. Correct. Now, if you
spell it in a wrong way, it's going to not be able to extract the information
from the data table. Sometimes when something
is not working, it's not extracting information. Just make sure you have
written this name correctly. Because this name
has to match with whatever you wrote over here, it's going to extract this
information from here. Now, again, as I
told you before, can make a space because
we have this replaced, it doesn't matter if
you make a space, it's going to remove
the space for you. This is why I added
the replace here. This is a skeleton Mage. I go back to the enemies and open up the next
one, Skeleton Rogue. Then we have the
skeleton like this. Then we have the wizard. Now we have all of
them and go out and click on Compile
on each one of them. Then you are finished here. Now they all have names. How it works now
is it's going to take the name of the enemy. For example, this guy
here is called a warrior. This a warrior, it's going to take the
name here, a warrior. And it's going to take
this information and then it knows what information
the a warrior has. This is why we added the name. We're going to use
it. Let's close everything down and let's
move on to the next lesson.
34. 4.14 Spawning the Enemy: Now let's go ahead
and spawn the enemy. Let's go back to the game mode. This is where we left
off the last time. Remember we got the
actor transformation for the spawn point. We basically know where
to spawn the enemy. Now let's go ahead and tell it which enemy to
spawn at what level. Now we have this information
because we created the function libraries
now inside of here, let's right click and
let's say actually we need the current level and we don't have that as a variable. I'm going to create it in the game mode because it
makes the most sense. Remember, the game mode controls the rules about the game. It knows what the
current level is. Let's make a new variable. It is an integer because
it's just a number. Let's call it current level. Let's compile because we need
to see the default value. Let's compile for
the default value. We start at level one. I'm going to change
this to level one. Let's strike this into here. Okay. The thing we
want to work with is the get enemy info because we
need the enemy class here. And plug in T and say break. Now for the class we
can plug it into here. If you don't want to see
all of these other pins, you can click on it and
say hide unconnected pins. Now for the enemy name, remember we have
the other function called get level info. From here, you can
see which enemy should spawn at what level. From here again
you can say break. Now you can use this enemy name. We have to give it
the current level. Now everything is good. We can click here,
Hide unconnected pins, and then drag this down. You can select all
of them and hit Q on your keyboard to
straighten them like this. Okay, let's put this down here. And put this up here.
Now it's going to work. As you can see, we have
the current level, we're getting the
information for level one. It's going to go inside of
the data table, level info, going to look at level one
and then it knows it's the Orc it's going to
output and the enemy name. And this is going to be
plugged into the enemy info which then extracts information
from the enemy info. Or now we have all
the information about the Orc including
what last to spawn. Because remember in the
Google sheet we told it the class that it needs to
spawn with it is BP Orc. It's going to spawn
the BP Orc blueprint. And here we are
spawning the enemy. Now if I double click this, it's going to take me to
the Player Controller where we made this event. It's going to spawn the Orc, and it's also going to spawn the Or at the spawning
point that we created. Let's go ahead and compile
and save everything. Let's click on Play.
And now you can see it is the Or, we can test this. If I click on the current level, I changed the current level to, for example, level three. At level three, it
should spawn the shaman. If I compile and
click up and play, you see it is the Shaman
that it is spawning. This is working correctly. Now to make it a bit more clean, what we can do is take
all of this and I can right click and
collapse to a function. I'm just going to
make a function out of this just to
make it more clean. Let's call this one enemy
to spawn or current level. Let's make it into a pure
function because remember we're just getting information
to pure function. Let's rename, let's
double click into here. I'm going to move
this down like this. Now for the first
one it is the enemy. So we're getting
which enemy to spawn. The second one here is the spawn transform,
just like this. Let's compile and
save everything. Now out here, it is
a lot more clean and we don't have
this line out here. Everything is looking good. Okay, that's how
you spawn enemies. Let's click on the
current level and set it back to one default. So now it is working. And let's move on to the next lesson.
35. 5.01 Designing the Enemy Name UI: Now that the enemies are
spawning correctly in the map, let's go ahead and
work with the UI. We don't have a folder yet. If I go to the content folder and right click and
make a new folder, let's call this one UI
inside of this folder. Let's right click and go to User Interface and create
a Widget blueprint. Now here, just go ahead and
select user Widget up here. Let's call this one enemy name. In this lesson, we're just
going to make the enemy name a very simple UI. Here it is. Inside of a wide blueprint, you have the viewport
you can click on, right click on the mouse, just hold right click
and pen around, almost just like blueprints. And here you can
see what you have added to your UI elements. Here are all the
elements you can add. Also again, you have a details
panel just like out here, where you click on things,
for example the text, and it will show
details about the thing inside of a widget blueprint. You have the designer
where you design the UI. And you have the graph where you program things on the UI. For example, what happens
when you press the button? If I go back to the
designer now for now, let's just design the text. It's just the enemy name, so it's just some text. But before we design, we
have to add a canvas. Before you do anything in UI, in Unreal Engine, you have
to add a canvas panel. Click here, rag it, and drop it on top of here. Now you have this canvas. Now we can add things to it. For example, in this case, we are only going to need a text if you just
search for text. Or you can also just go down
here, you can find it here. These are the most
common elements here. You can also just click
around, see what there is. If you want, just for practice, you can always click and
drag this into here. You can see what it does. You can try to play with
some settings, doesn't hurt. When you're finished training, you can just click here and hit Delete on your keyboard
and it will delete it. We have the canvas panel, let's add some
text on top of it. You can either add
it on top of it here or you can
add it over here. That is the same thing.
I usually prefer just to drag and drop it
on down here instead, but it doesn't really
matter for now. For this text, we don't really
need all of this space. What I'm going to do is I'm going to click on Fill Screen. And then desired that it's only going to
fill around this text. Now you can see it
is off centered. You can see this is because we have something called
the Anchor point anchored to this corner. And what that means,
the Anchor Point, what it is, is let's say this is your game window,
you're playing the game. Now when you rescale
the game window, the text is not going
to stay down here. It was your intention that the text should
stay down here. When you rescale the window, the text is going to move
towards this anchor point. If your intention that the text should stay down
here on your screen, then you're doing it wrong
because it will just slowly move to this direction
when you resize the screen. Very important to set the
anchor points correctly. Now for this anchor point, I just wanted to
center it on the text. I'm going to hit center on my screen.
This is your screen. I'm going to center it to
my screen and I'm going to write 00 in the position
of the x and y. Now when you write 00, the anchor point snaps to
the upper left corner. To fix this, you can
play with the alignment. Here you can see 0.5 is the middle and one
is the other side. It's usually 0-1
in the alignment. The same thing for the Y. 0.5 is in the middle and one
is on the other side, 0.5 and 0.5 That will
add it to the sensor. Now you can see my text, and this is what I
like to have it as. Okay, click on Compile
and save everything. Now let us go ahead
and stylize this. But before we do this, when you design UI inside
of Neural engine, you have to make sure that
your looks good on laptops, It looks good on Noble monitors, 24 inch monitors,
27 inch monitors. It also needs to, for example, look good on my four K monitor. If you don't design it good on my four K monitor, it
might look like this. And I will have a bad
time playing your game. How do we make sure
that the UI stays good on all screens?
The way you do this is clicking up here on
the screen size. I usually design my games for
a generic 14 inch notebook. Go ahead and click this, and this is what it will look like. Now just pay attention
to the zoom up here that you're not
zoomed in, plus eight. If I zoom out, now you can
see it's also minus ten. If you just zoom until it is 11, then this is what it actually
looks like on a laptop. What does it look like
on my four monitor? Well, if you click down here
on this settings button, then you can see
how much it scales. Right now, we are designing
it for a 14 inch laptop, but on my screen, on a four K monitor, it will scale the
UI by 3.8 times. It is going to be
3.8 times scaled. Now it is too much. Let's just scale this down. And I can show you if I click
up here in the scale eight, you can click on it and then
you can reduce it here. I usually find it to be
good on my four K monitor. If I set it to 2.5 it will
scale nicely on all screens. It will not look
bad on my screen, because for a laptop or
for my four K monitor, it will scale 1.6 times and it will look
good on my screen. This is what I found
will look good. Usually three is too large. From my four K monitor, the US is too large. 2.5 is really good. Okay, so now it's scales
correctly on all screens. Let's go ahead and
compile and save. Now let's click
on the text here. And let's stylize
it a bit, right? The way we stylize it is
we have to select a fund. You can see right now
we don't have funds, we have the normal
fund and we have to download a custom fund
in order to stylize this. So let's go ahead for now in the next lesson and
stylize this text. We can download a custom fund
and add it to real engine.
36. 5.02 Adding a Custom Font: All right. So if you go to Google and you search
for Google funds, you see this website called Funds.google.com
And inside of here, you can download
whatever fund you want. Now, you can also just search for funds and you
can even download free funds. There's also a website called
The Fund, The Fund. This one is good as well. It has a lot of funds that
you can download from. There are also paid ones. Now I love the Google funds, they have a lot of cool styles. From here, I found
one called Playpen. Search for Playpen, and this
is the one I want to use. Now you can choose
whatever fund you want, doesn't have to be
the same as me. And you can always
test the fund. If you write something
here, for example, we can say, Skeleton
Mage for our game. And you can scale it down to
see what it looks like if it was like this and it
is bold and so on. So I like this fund. I'm going to hit Download, and I'm going to open
it up here, here it is. Now for this fund, I
have to extract it. I'm just going to take this static folder and extract
it to my downloads folder. And I'm going to go in
my Downloads folder, going to double click on it. This one, this one that I extracted here, I
have all the funds. Now I'm not going to
need the thin one. Usually they are
too thin inside of vulnerable engine
for games I like to, let's have maybe the
regular as well. Medium semi bold, extra bold, bold. That is it. If I go back to my engine, I minimize this here, and I minimize this as well. Now in here, let's
minimize this. Let's open up my folder. Now, I can import all of
this in the UI folder. I want you to make a new folder and I'm going to call it funds. If I can spell inside
of this funds folder, I'm going to click and drag
all of this into here. Remember, you have to
extract the funds first. Before you do this like we did, would you like to create
a new fund asset? I'm just going to say apply to all DS. And here we have it. Very easy to import funds. Go ahead and save everything. Now if you go back to the
enemy name, we click on it. Now we can choose this
custom fund for it. Now for this one, I
think I'm going to use this one called Extra
Bolt Like this here. This is looking good for me. Here. For the justification, I'm going to center it. I'm also going to click on
actually this text here. I'm going to say
size to content. It's just going to size
however large this text is. I don't have to worry about
the size on the X and Y. S. You have to test
it out in your game. But I think for me
I'm going to go with 28 And the front size, we can also give it a color. If you click up here in
the color and opacity it a color. I'm just
going to give it a slightly red color,
something like this. And hitting okay, I'm going
to give it an outline. If I click here in the
outline, I can write one. For example, you can see there
is an outline on the text. I think I'm going to go
with two because you can almost not see it when
you are zoomed out two. I'm also going to
change the color for it to just copy the color
from the first one. Actually what you
can do, you can also hold shift and right click to copy shift and left
click to paste it here. I'm just going to make it Daca and I think this is good for me. Now, a very cool
effect you can do in oral engine is here
in the shadow offset. If you copy the same
color, so I copy this, click down on the shadow
color and I can also paste it here on the shadow color,
here in the offset. I'm going to write
zero in the X. Let's write something
like three in the Y. You can see a very cool effect, you have the text and
then you have like a cool brown
background behind it. We can always test it in game
to see what it looks like. Sometimes I actually
wait with designing it until I have it in game so you can see what it
looks like in game. But for now, I think
this is really good. Just to make sure that the text is not blocking
anything in the game. You have to go down and in
the visibility you have to set, not hit testable. What this means is if
you try to click with your mouse on something behind the text,
it's going to work. If you have it set to visible, then the text will block
your mouse clicks, and if there's something behind the text, you
cannot click on it. Now, we prevented
the block here. Go ahead and click on
File and save All. And here is the enemy name. Now we are ready to add
it in the next lesson.
37. 5.03 Adding the Enemy Name UI: Now to add the enemy name. Let's go to the blueprints. And let's open up the enemies. And we have to add it
in the enemy base. Remember, the enemy base is the parent for all of
these child blueprints. Let's go to an enemy base. And if we add it here, it
will be added to all of them. Going to click on Add
on the Components. And if you search for
widget, here it is. Go ahead and add the
widget to this enemy. We can just call it enemy name. Maybe I'm actually
going to call it enemy name widgets. So we know. And let's go ahead
and save everything. Now for this enemy widget, go to the viewport. And now we also have to just push it down a little bit
so it's beneath the enemy. The name is beneath the enemy. Now for the enemy widget
in the details panel, I'm going to set it to screen. The text can be world or screen. I'm actually going to show
you an example here, Sophie, just click on the widget class and select our
widget we just made, that will be enemy
name. Here it is. Go ahead and compile. I'm actually going to show
you what it looks like. Just so you can see, if I pull in the Roe, I write zero in the Y. Here is the enemy's name. You can see if I'm looking
at the enemy like this, We can't see the text because
it is displayed like this. What happens when you click
on screen is you just display this text towards
the screen, just like this. If I click on play now you can see it displays
towards the screen. This is now looking
good. Let's open it up. Let's click on it again. I'm just going to hit
Draw a Desired Size. And now we are ready
with this one. Let's click on Compile. And you can push it down
even further like this. You can always just click
Play and see what it is. Now I think for the enemy name, I'm going to push
it to maybe like -22 Just a bit more. Here it is. Looking good. Let me just delete this one so we don't have
two enemies spawning. Now this is the enemy name
that we have displayed, and everything is looking great.
38. 5.04 Programming the Enemy Info UI: All right, instead of only
having the enemy name, I decided to add the
enemy level as well. It will look a bit cooler. Let's open up the enemy
again, inside of here. Let's actually go to the UI, open the enemy name. I'm just going to rename
it to enemy info instead. Now inside of here,
if you click on it, we actually don't need to
do anything inside of here because we are going
to program the text. We don't need to
change anything here. But now let's go
to the enemy base. Instead of enemy name wide. I'm just going to
rename it Info Widget. And this is because
we have the name and the level displayed. Decided. Okay, we don't
really need to do much here. But what we need to
do now to program it, is we need to go to the graph. Now let's delete all
of these events. Let's right click
make a custom event. Let's call this one update
enemy info I for this one. Now when you do
something in code, you have to think about what is it that
you're trying to do. I'm trying to update this
text. This text here. Clicking on it, I have to
set it to its variable else I can't see it as a variable here and I
can't do anything with it. So I'm just going to call this one text enemy info
and set it to is variable. And then going to graph. Now I can see it, drag it in. The thing we're trying to do
is set the text, set text. And you can select this
function called set text. This is how you set a text here. Now this is what
you're trying to do. We're trying to set this text to be the name of the enemy. Now obviously we don't have
the name of the enemy here. Remember we have the
name of the enemy. Inside of the library
function that we created, we also need the enemy's level. Now as for the level, we have this inside
of the game mode. If you go to Blueprint to
open up the game mode, remember here we have the
current level as well. The best practice to do this is to update the enemy's name
whenever the enemy is spawned. I'm thinking here
in the enemy base, whenever the enemy spawns this begin play
is going to play. It's nice to add this
code inside of here. We need to do, instead of
writing the text here. Now we need two inputs. In this function, we
need the enemy's name, and this is a string. Let's make it a bit larger so we can see this is
the enemy's name. Let's call this one enemy name. Then we need the enemy's level looking here, selecting integer. And this is the enemy level, just like this enemy's
name and enemy's level. Now to plug this in here, as you can see, we only
have one text block. To add two dynamic values
into one text block, you have to use something
called a format text. This will allow you to
add to multiple inputs, or multiple inputs
into the text if you drag here and say format
text like this one. Now how you use this is you
start with a cur bracket. The first thing is we
need the enemy name. Let's say enemy name. This doesn't have to be precise. You can write whatever
you want here. Let's close the curly brackets. When you do that and hit Enter, you can see you
have an entry point here that you can plug
it in with like this. Now we also need
the enemy's level, how we want to display it. For example, just
to visualize it, let's say for example, Orc, we have a comma and it says level one or level 12,
something like this. Here we have to
format it as well. Like this here we
have the enemy name. Then we have A. Over here I'm
going to right and level. Then we have the level. I'm going to open up
the curly bracket again and say enemy level. And close it again like this. Now I can add this input now it's going to
display directly for me. All right, this one we can
add now to the enemy base. If I compile and I go
back to the enemy base, let's just delete
all of this for now. And how we do this is let's
take the enemy info widget. First you have to write widget, select this one called
get user widget object. Now here I usually
cost, say, cost two. I usually don't use a widget
blueprint for the UI because I think it's too much to create a widget blueprint
to every single UI, you only need to cost to UI
that is inside of an enemy. For example, the main menu UI, you're not going to
cost two however. The menu that is indented
inside here as a component you are going to cost to
get user bridge past two. And we called it Enemy info. Go ahead and select it here, and let's go ahead
and connect it. Okay, so here we have it. Now we can call the
update enemy info, update Enemy info Ui. Now we have to plug
in the enemy's name. And remember we already
have that here. Remember we click on
every single enemy and we set the enemy's
name, all of them here. And this is when we use it. Now let's strike this, plug it in, this is
the enemy's name. Now for the enemies level, we have this as
the current level inside of the game mode. I don't remember in
the interfaces we made an interface for the
game mode, we did not. So let's go ahead and create
the blueprint interface. Let us right look here, Go to Blueprint and select
Blueprint interface. Let's call this one BPI. Now, I'm just going to call
it game mode because we only have one in the game.
Let's open it up. Now, inside of here,
let's call it get game mode reference because this is what we
are trying to do. For the outputs, you have to
select in the variable type, what you are trying
to reference to. Now I'm trying to
reference to my game mode. I'm going to search for
the GM Dungeon Clicker. This is what I called it,
this is my game mode. And I'm going to select
Object reference here. I'm just going to
call it game mode. Go ahead and compile, Save All. And now we are finished
inside of here. Let's close this
down. Now we have to add this blueprint
interface to the game mode. If I go back to blueprints, open up my game mode
inside of here. Let's go to the clause settings in the implemented interfaces. Let's add the blueprint
interface, game mode. When you do this, this
function appears. Let's double click on it, rack from here and say self. Now we are defining
this variable. We're telling it that this
game mode variable is self. Meaning that whatever
blueprint we are in right now, telling the engine that
this game mode variable is GM, Dung clicker. Okay, now we are finished.
Let's close it down. Let's open up the
enemy once again. And let's continue the work. Instead of doing this first, let me just move all of it here. Let's disconnect it by
holding Alt and clicking, let's right click and
say Get Game Mode. Now for this game mode, we are getting the
general game mode, the default game mode,
and Unreal Engine. Instead of saying cost to GM, instead of doing
this, now we can say it, game mode reference. And we can use the blueprint
interface function. And you know this because
it says message in the end. You know it comes from
a blueprint interface. Let's close the sound. Let's go out and connect it now. Now with this, we
can right click and promote this to our variable
and call it game mode. We don't have to do all of this again. It's a lot cleaner. Now, we can just use
the game mode variable. Let's connect it, let's
strike everything together. Let's go ahead and
use it. So now we can use the current level. If you go back to the game mode, if you don't remember, we have this variable called
current level. This is what we're trying to
use break game mode here. Search for current level and go ahead and
get current level. And now you can connect it and everything should
work perfectly. What is happening right
now is we're getting the update enemy info UI. We're plugging in
this information, the enemy's name
and enemy's level. It's going to take
this into the UI here. I go to the graph. Going
to plug this into here, should display it correctly. If I click on Play, now it says Orc level one.
That is correct. Now if I go back to
the game mode and I changed the current level
to something like five, for example, and
I click on Play, it says Wizard level five. Everything is working perfectly, okay. Everything is working. Let's go ahead and save.
And let's move on.
39. 5.05 Applying Damage to Enemy: Let's now go ahead and
apply damage to the enemy. Now if we click on Play, what I want to do is whenever
I click on this Orc, I want to apply damage. And by the way, remember
to go in the game mode and set the current level
back to one by default, because we set it
to five the last time we set it back to one. Now what I want to do first is you can see our
mouse disappears. Whenever I click in the
game, my mouse disappears. So let's go to the
player controller. And inside of here in
the class defaults, let's click on show mouse Ursa. Let's compile this. Let's
open up the enemy base. Before I do anything, let's actually go to fuel
Debug widget reflector, make it 1.25 So you
can see here in here, what I want you to do is
for the capsule component, this is the one we're going to interact with whenever
we click on it. What we want to do is let's go down in the
capsule component. And here you see some
events that you can use. What I want you to use is
this one called click, because we're going to
click the enemy unclicked. Go ahead and select that. And here what I want you to do, also drag and say print string. Print string is very powerful. This simply prints a
string to the screen, prints a message to the screen. For example, it can say worked. And what I use this for
is to debug my code, I want to see if my event
is actually working. Again, this is super powerful. This is how I debug my code. If I have an error, for example, let's say something was not
working here somewhere, I would take this and paste
it up here, for example. I would put it here beside
this, or between these two. If it prints out, this
means this part is working, then I would print out here and see if this part
is working and so on. Keep printing messages to the screen and this is how
you debug effectively. Down here on the click,
Let's see if that works. If I click on play and
I click on the Orc, nothing is really
printing to the screen. This means that
this event is not really working.
Something is wrong. This is because in the
capsule component, let's check the collision
settings down here. We set it to no collision. Of course, it's not
going to work whenever I click on it because this
guy has no collision. When the collision presets
instead of no collision, let's click on it and let's say custom for the
collision enabled. I'm going to set it to
query only now physics. Whenever a character is walking on the ground
and there's physics, they don't fall through
the ground and so on. We don't really
need physics query. For example, your
mouse is interacting with the enemy query on. We don't need physics. As for the response
channels, ignore everything. We don't want to interact with other world static objects, pawns and vehicles and so on. The only thing we want to
intact with is the visibility. Visibility is your mouse, this one we want
to interact with. Now if you click on play, we click here, You see
nothing is happening. Still something is wrong. Now let's open up the
play controller again. And here you see
enable click events. You have to take that as well. Compile, click on play, and now you can click on it. Now you see our message
is printing to the. Now it is working again. You can test the hit box, depending on how large your collision sphere
is, our capsule is. You can see when I click out
here, it is working as well. I think this is a fair hit box, but if you want to
fix your hit box, you can always go
to the enemy base, click on the capsule component, and you can increase and decrease the half height
and the radius of it, depending on how large you
want the circle to be. The thing we want to
do is apply damage. Let's here and say Apply Damage. There is a function for
this to go ahead and select Applied Damage
for the damaged act. To damage self, we want to
damage this enemy base, whatever enemy we
are pressing on. What do we want
the damage to be? We can just add a static damage that we can upgrade
later in the shop. For the damage, I actually
want to add it to the player. That makes the most sense. If I go to blueprints, I go to player here. Let's add a new variable
called a damage. Let's change this
into a float compile. Let's just set it
to 15 by default, we can change it later. Compile. If I go back
to the enemy base, now we need a reference
to the player. See here, if we
have an interface, we don't have a
blueprint interface. If you want to
challenge yourself again with the
blueprint interfaces, go ahead and create
one for the player. But now let's do it together. Let's right click, go to
blueprint, blueprint interface. Call it PPI layer. Let's open it up here. Let's say get layer reference. Now down here, whatever
we are referencing to, we're trying to reference to BP player. Let's
search for that. Go ahead and select it. Let's call it Player. Now let's compile. Remember to compile now let's go back to
the player and add this blueprint interface inside of the cloud Settings down here, search for BPI, Add the
player, compile down here. Let's open it up and
make a self reference. Just like before, we define that this variable type
is this player. Now we have done this, let's go back to the enemy base here. Let's do it after the game mode. If I just strike here, let me right click and
say get player character. Go ahead and select then let's strike from here and
say get Play Reference. Select this, go
ahead and connected. Let's right click and promote
this and call it Player. I'm just going to
call it Play Upon. Let's connect here. Just drag this over. Now we have this
reference ready and we can go ahead and use
the variable s out of it. Let's go ahead and use the
cursor damage down here. Let's take the play up, let's search for cursor damage, select it, and go ahead and connect it here. Just like this. Now, we don't need to do
anything with those to see if this is working and we're
going to be using it later. But what you can do is
you can write click, and search for any damage. We are going to use it later. You can print a
string from here. You can just print the amount of damage that we are causing. Let's, let's click.
And when I click, you can see I'm applying 15 damage and everything
is working as expected. Let's go ahead and just
delete this for now. Let's actually delete this. We can make it in
another lesson. Let's compile, let's save
everything, and let us move on.
40. 5.06 Calculating the Health: Let's now work with
the any damage event. If you're right click
here in the Enemy base, you search for any damage.
Let's use that one. This is used for when
ever you apply damage, you go here and then you
calculate the damage, and then you apply
whatever damage you have done. Let us do that. Let's make a new variable. We need one called
current health. Now for this one, let's
change it into a float. Let's compile. Now for
this current health, we need to have health. Because we can't really
start with zero. The enemy doesn't have zero, so we need to set it somewhere. Remember before in
the data tables we made in the enemy info, we added health to the enemies. Let's go ahead and
use that and set it by default
whenever they spawn. The best way to do
this is here in the Begin play whenever
the enemy spawns. Let's take this current
health and set it. You hold Alt and drag to set it. Let's set it to whatever it was in the data table.
Let's right click. Remember we made a
library function called get Enemy info. Now it needs the enemy
name. And we have that. Remember we are inside of enemy base and we
have the name here. Let's drag it and plug it in. Let's strike from
here and say break. When we break, we can see all of the variables for this
enemy info function. Now let's just set it
to the health here. We start with whatever
health we have written here. Let's go back to enemy base. Click here, Hide unconnected pins to make it look cleaner. And let us connect it. Now this is working down here. Now we have the current
health set correctly. Whenever we do damage, I want you to take
the current health, let's say the current
health is 100. For the first one here, we're going to say 100 minus. If you just write
minus or subtract, subtracting the
damage we have done, it would say 100 -15 That is equal to
whatever it's equal to. We have to take this again
and set it back into here. It is updated now we
say 100 -15 is 85. 85 is going to be here. Now, just to make sure that
we don't go below zero. Because you can imagine
if I keep doing damage and it reaches zero and I do damage again, it's
going to say zero, -15 that is -15 Instead
of going to minus health, we use something called a clamp. If you drag from
this and say clamp, select this one
called clamp float, because we're working
with floats. Clamp float. What clamp is, is basically
you clamp the value, so it can never go
beneath zero and it can never go over
some value you add here. I'm just going to add
this current health to it because we're not
really healing the player. I'm going to clamp it
between whatever it is right now and we can't
go beneath zero. I'm going to plug
it in like this. Let's go ahead and
connect it here. Now that is actually finished, you can now double click on
this, make it look better. Go ahead and do this.
Let us just use a print string again and see if we are doing
it correctly. If I compile, click on
play and I do damage. So now it's 85,
and then it's 70, 505-402-0510, and
then it is zero. And you can see
whenever I click, it cannot be below zero. So now we are calculating
it correctly.
41. 5.07 Designing the Health Bar: To design the health bar, let's go over to the UI
folder. Let's write. Click now, let's go to user interface and create
a widgit, blueprint. Again, a user widgit. Let's call this
one WB health bar. Let's go inside of here. Again, just what I said before, screen size. Let's click here. Set it to a generic laptop
we designed for all screens. Let's create this canvas panel. Remember, we always
have to add a canvas. Now for the health bar, I included something for you. We didn't import it yet. So let's go to the
cost materials here in the cost materials, I want you to go
to the UI again. You might have much more
UI than what I have now. This is because I just
keep adding to it whenever I keep
developing this course. Let's now take this
one and this one. That's what we need so far. Here, let me right click, make a new folder, call it
images. Let's open it up. Now let's open up the
cost materials once again let's drag those
into this folder. And now they are uploaded. Now this is picks a lot, so I don't want it to be blurry. Remember, you could just
select both of them. Right click and go to Spot Actions and apply
paper to the settings. Now it is not blurry
anymore, it is looking good. Let's go back to the Health bar. And inside of here,
let's search for now. I want the text to be on top, and then I want the Health
Bar to be beneath it. We need a vertical box for this. Take a vertical box at it. Inside of the vertical
box, I need some text. I'm actually going to copy
the text that we made here. I think it's looking good. And we can just
change the color. Click on the text
control C to copy here. Click on the
vertical box control V. Now for the health bar, it is just if you search for progress bar
and this is what it is. Drag it into the vertical box. Now for the vertical box, let's resize it so we can
actually see what's going on. Now instead of having it
fill the whole screen, we want just like
this enemy info, we just want it to be
whatever size it is. Because we're just going
to use it in game here. We don't need it to fill
the whole thing again. Click on Fill Screen. Up here to desired on screen. Instead of the anchor
point being up here, let's change it to the
middle of the screen. Let's change the alignment
of the vertical box to 0.5 by 0.5 and the position
to zero by zero. Now it is in the middle here. Okay, looking good. Now for this progress bar, I'm
going to click on it. And for the style, let's
change the background image. The background image
is this progress bar. The fill image and
marquee image, they are both this
bill that we have, this one and this one. And let us click on Compile. And we can see it's not looking too good when we look at it. And this is because here, I believe it's the marquee. I always forget here in the
marquee image size in the Y. We can change it.
And now you can see it's actually changing. We can change whatever
size we want to. For this one, I think I'm
just going to make it 45. You can also scale it here
in the X and y in the X. You can also scale it. Now we can't really
see a difference because this vertical
box is blocking it. Because we can scale it here. But I'm going to scale it here in the size to content.
I'm going to click this. I'm going to scale
the vertical box, depending on how
large the content is. Now for this bar, I'm going to reduce the size to
something like 250. We can always make
it larger later on, but it's looking good now. Now let's see if this
fill is working. Let's go down and you
see this percent. You can click and drag to
fill it in the percent. But you can see the
color is not correct. It is down here in
the fill color. Instead of being blue, I'm just going to set
it to be white. And go ahead and
click. Okay. Now you see it is looking good. Okay, now we have designed this. Let's change the color of the name up here
or not the name, it's basically the amount of health for the
amount of health. Let's change it to
maybe a more red color. I've chosen this color here. I think it's looking good. Now let's copy this. Basically just hold shift, right click, shift, left click
on this one and this one. Instead of being this color, let's just make it Daka. I think this color is
looking good as the outline. Let me just copy
this. Go in here and paste it in the
hex linear color. Click. Okay, I think this
color is nice for the health. Now we are finished with this, you can give it a bit of space. You can see it's too close,
maybe to the health bar. You can click up
here, you can go to the padding up here
to the bottom. We can give it a padding of six. It's a bit pushed away from the health bar, now
it's looking good. Again, I'm going to click on the health bar and on the text, and change the visibility
to not testable. So we can't interact
with it, with the mouse. They don't block the
mouse in the game. I'm going to hit. Okay.
Now this is finished, so let's go ahead and move
on to the next lesson.
42. 5.08 Adding the Health Bar: To add the health bar. Let's go to Blueprints
and open up the enemy. Once again, let's go
to the viewpoint. Let's click on,
just click up here. Go to Components. Search for again for Widget, just like what we
did with the name. It's the same concept. You can try to do it
yourself for practice. Let's go ahead and
click on Widgets. Here we can just say health Bar. Now click on, I'm just
going to say health widget. Maybe health widgets. Because if you keep coding on the game and it becomes
a very large game, it's always nice to have very descriptive names so
it's not too confusing. Click on the health par widget. Let's change the
space to the screen. It always displays
the UI to the screen. Let's change the clause
to health bar tick. This one called Draw
a Desired Size. All right, let's click Play and see what it looks
like. And here it is. Let's strike it down
beneath the name. Click on it, Wrike. Strike it down a bit
here. Click on play. And let's strike
it even more down. Click on play. This
is maybe too much. Instead of -40
let's say minus 37. Click on play. I think
it's looking good. Maybe minus 36, now
it's too much OCD. Click on play. This is
looking a lot better. Maybe this is what
we can go for. As you can see, we still need
to update the health bar, both the text and
the health bar here. Let's do that in
the next lesson.
43. 5.09 Updating the Health Bar: All right, to update
the health bar, let's first go to the UI. And let's open up
the health bar. Inside of here, let's
click on the text first. For this one, instead
of text enemy info, it's called text health. The second one here,
the progress bar, I'm going to call
it progress bar. Let's just also call it
make it variable so we can. Let's go to the graph now. Let's delete all of
this. Let's write click and make a
new custom event. Let's call this one update. Now for this one, what
we're trying to do, again, whenever programming, just think of what are you
trying to do right now? I'm trying to update
this health bar. Okay. How do we update
this health bar? The way we update it is you're trying to
change this percent, you're trying to change this. There's always a
good stock to just analyze what you're trying
to do for this percent. Let's go to the graph and
let's take this progress bar. If you don't know what
it's called, just try to search for percent. You can already see here, you can use this in
set percent function. Let's go ahead and
connect this set percent. You have to take a look here. The percent is not 0-100 0-1 We actually have to
do some division here. Because here in
the update health, this one is going to be called within the enemy base whenever. Remember here we
calculate the health after we do damage
that we did that. From here we can call
this update health UI. Here we can have a plug
in to the current health. I'm going to click here, Make a new variable, just regular here,
so we can see, make it a float, Call
it current health. Now, how do we divide this if you're not
too strong at math? For example, let's say
health is 100 divided by, so we can do this
sign or right divide. We're going to divide this by a number which is
the max health. Because for example,
you can say, let's say I do damage to this enemy and the
enemy has 100 health. The damage right now
for the cursor is 15, it says 100 -15 it's 85. Then you can say 85/100 and
you will get the percent. If you're not too
strong in math, you can always take
here your browser. You can say, let's say
we have 85/100 Enter. And then you can see it's
actually displayed correctly. Okay? So this is the way
we want to do it because the maximum is
100, which is one. This percent goes 0-1 Let's
say current health divided by max current health
divided by max health. This is the percent, Now it's going to be correct. Let's compile now. Let's go over to the NM base
and try to use this one. Remember, you have to do costing now because you are
inside of the health bar. This is the same concept as
what we did with the name. Let's do that. Of course, you can go ahead and create a
blueprint interface for it. It is not a bad idea. You can do it, it's fine. But I think something that I'm only going to
cost to one time, like I'm only going
to use this function in my whole game,
maybe two of them. I don't want to create a blueprint interface for
every single UI I create. Let's go ahead and
delete this print node. What we can do now, let's just make a new custom event here. Let's make a custom event
called update health. And this one is going to
call the update health UI. Let's drag this widget. Let's do get us widget
object just like before. Let's say cost two
and we called it health Cost to health Connected. Here we want to call the
update health drag update. I go ahead and
connect everything. Now we need plug
ins to the current, current health and health, the current health we
have already here. Let's go ahead and connect it. Because we set it over
here so we can do that for the max health, we need the max
health of the enemy. How do we do this? Remember,
we made an enemy info here, it's basically this one. You can basically just
copy this control C, go down here, control V, or you can rewrite it if
you want some practice. Try to write this again
and see how you did it. Let's go ahead and connect it here. Now we're
updating the health. Remember, we have to run
this event before it works. I'm just going to run
this update health every time I do damage. Over here we can call update
health and call it here. Now what we're doing
is we're doing damage with the mouse,
we're applying damage. And the damage we apply, we're calculating it and updating the current
health for the enemy. Then we're updating the I here. Actually, here, update health. Maybe we can have this
one down here just so it makes more sense
Programming wise, I'm going to take
this out from here. I'm going to make
an input down here, a float called the
current health. I'm going to plug it
in like this instead. We can plug in over here. I think it makes more sense. We can do it both ways, but sometimes when you program, you can do things multiple ways. But some ways are better
practice than others. I think this one is a bit better because we're updating the current
health over here. Okay, update health
is updating here, and then we're updating the UI which updates
the health bar. At first it's going to be 100, but if we click Play, you can see it's still zero
in the health. This is because it's
only going to update. Now whenever you
click on the enemy, as you see here, if you don't click on the
enemy, it's still zero. This is because we have to run this code whenever
we spawn the enemy. Up here, when we update the enemy UI and we update
the current health, I also want to say
update health. And do this instead
of doing it here, remember we already set
it inside of this event. We can delete this
and we can just plug it into here
instead and connect it. Let's compile and click on play. And now you see it is set to full whenever the enemy spawns. Whenever I click it
is going to go down. Now it's working now we
just need the final thing, and that is to update the text. That is a lot easier
to do for this text. Let's drag it out and drag
here and say set text. Let's do set text here. Now for the text we
need to set it to whatever the current health
is. Drag it into here. And drag this down again. Double click on it,
make it look better. Compile and click on play. Now see the health is 100. If we click, it's
going to go down. Now we can try it again
on something else. If we go to the blueprints, open up the game mode,
the current level to something like level three. Whenever I click on the enemy, it's going to update
the health correctly. Again, now everything
is working, and let's set the current
level back to one, compile, save everything,
and let's move on.
44. 5.10 Enemy Hit Flipbook: Now that the damage is working, when we click on the enemy, the enemy gets damaged. To make it a bit
better, let's play the hit effect when the
enemy has been hit. That will look a lot better. Remember inside
of the data table we already made in
the enemy info, we already added the hit
animation flip books here. Let's go and use those. Let's close this down.
Let's go back to enemies. Open up enemy base. Inside of enemy base. Let's go down here and
make a new custom event. Let's call this one hit effect. Let's do that here. We simply
want to play the flip book. The enemy hit flip book again, just like before we can
take the flip book. It's basically this sprite here. Take the sprite dragging from the sprites and you
can write flip book. You can try to read. What
you can do with all of this. The one we want to use is this one set flip
book because we want to set it to the flip book, we already have the flip book
inside of the enemy info. I'm actually just going to copy this up here. Paste it down and here let's hide
unconnected pins. Let's click down here. And I'm just going to
show the hit animation. And then I am going
to connect it here. Now it's going to play
the hit animation. Now the hit effect.
Whenever we click now you have to
see where does it make sense to call this event? It makes the most sense whenever
the enemy takes damage. After you update the health, you also play the hit
effect event down here. And it's going to
play it. I click on Play and click on the enemy. You can see it is playing it. However, right now
it is on forever. We have to fix that. We have to set it back to the normal flip book after
the enemy has been hit. What I'm going to do is I'm only letting this hit flip book, going to play once and then I'm going to switch
back to the normal one. The way we can do this is we can take this sprite here, we can drag here
and say flip book. You can try to read
what you can use here, the one going to
use is this one. Get flipbook length. Then I'm going to delay
by this amount of time. I'm going to delay it by the
length of the flip book. After this is finished, we can take it here. Instead of copy pasting this, I'm just going to use
the idle animation here. Let us set it back like this. Just copy this, set flip book here and you can set
it back down here. I will click to make
a rear route node and something like this. This should work just nice. We can try to play now if
we click on the enemy, and here it is now
I'm going to increase the amount of time this
hit effect is playing, because it's playing too
slow and looks weird. I'm going back to my assets and opening up the characters. Now for this hit, we have to increase the frames
per second here, so it plays a lot faster. The way we can do this is I
just click Control Z here. If I just select all of the
hit one, just hold control all of the hit flip books. What you can do is
right click again, asset actions, it selection
via property matrix. So you can edit all
of them at once. And then let's set the
frames per second. I'm going to set to
40 frames per second. Let me just save all play
and see what it looks like. This is what it looks
like. It looks a lot better like the
enemy is being hit. That was it for the hit
effect. Very, very easy. Now let us go ahead and
work with the enemy death.
45. 5.11 Enemy Death: Now for the enemy death, obviously the enemy dies
whenever the health is zero. It makes the most
sense to do it here. Whenever we damage the enemy, we check if the
current health here, we're actually not
checking anything. We're basically just calculating the current health and
we're updating the health. Before I even update the health, I want to check if my
enemy is dead or not. Let's go ahead and do it here. Whenever the health is, the enemy should die over here. I'm just going to drag
and say if the health is greater than zero
and make a branch go ahead and connect this. Whenever the health
is greater than zero, we just want to continue
whatever we did before. However, if the health is
not greater than zero, this means the health is zero because we
clamp it at zero, so it can't be negative. If it is zero, Let's go ahead
and make the enemy die. I'm just going to
make a new variable, a bullion called B is dead. I usually add a B in front
of my bullion variables. And you can see if you drag it out here, you can't see the B. This is usually done in
C plus plus and it's also a lot easier to search for if you
have a larger game. Let's now add it and set it to true. Whenever the health is
not greater than zero, it means the enemy is dead. So we can set this to be true. Also, just continue updating the health
because we have to update the health as well
and do the hit effect. Now for this one we can double click and make a
rear route nodes, it doesn't look bad,
just like this. Now what can we do with
this one? With this one. Obviously here in
the hit effect, whenever we hit the enemy
that we did before. I don't want to play
the idle animation whenever the enemy dies. Let's take this bully in here. After we delay this, the sprite book length, we make a delay. Instead of playing the
idle animation instantly, we have to check if the
enemy is dead or not. Let's strike here and make a branch and ask,
is the enemy dead? Yes, the enemy is dead. Okay, then we want to
play a death event. We haven't really
created one yet, so let's just go down here, right click, Make a new
custom event called death. We can do something
with this later, but up here if the
enemy is dead, I want to play the
death event down here. If the enemy is not dead, I want to play the idle
animation like I did before. Let's just delete this one
and reconnect it here. And double click once again. Okay, over here in
the death event, what we want to
do, we simply want to play the death animation. So let's again,
just like before, take all of this here
together with the delay. I'm going to copy it. I'm going to paste it down here. And I'm going to
connect it like this. Instead of playing
the hit animation, I'm going to disconnect it, hide everything, and only
display the death animation. Go ahead and connect that one. Instead, we're
going to delay it. After we delay it, I
want to destroy Acta. I want to remove this
Acta from the map. Let's go ahead and
click on Plane. Now, whenever I
click on the enemy, now the enemy dies. You can see the enemy
disappears. And that looks good. Basically you can see
the death animation is weird as well, the enemy falls. We
have to fix that. Before we do this, we have
also to increment the level, because when the enemy dies, we want the next
enemy to be there. I can also see I
just saw a buck. If you click too many times, you can keep clicking and
I don't want to do that. We have to also do a check
over here in the unclicked. We don't want to click the enemy whenever the enemy is dead. Let's move this and
say if the enemy is dead. And I'm going
to write not bully in. This means if the
enemy is not dead, If is dead is false, this is what it means here. If the enemy is not dead, then we can make
a branch here and ask if the enemy is not dead. We can go ahead
and apply damage. If the enemy is dead, we don't want to do anything. Let us click on Plan now and
see if this bug is fixed. And I can spam, you
can see box there, so everything is working again. The animation of the death is
weird. We have to fix that. But let's go ahead in
the next lesson and work on the incrementation
of the level.
46. 5.12 Incrementing the Level: Okay, to increment the level, I think it's best we do it
in the game mode because this is where the current
level is controlled. Let's do it here, over here. Let's make a new custom event. Let's call this one
Increment Current level over here. Very simple. We just want to take
the current level we want to drag
here and say plus, plus because plus plus means you incremented by
one and then you set it. It's the same thing as
doing this and saying plus one and then you
set it like this. It is the same method. This is a lot shorter. Again, remember, plus
plus means you add one. If you need to add
two in the future, you can't do it like this, you have to do it like this. But it doesn't
really make sense. Our level is just
incrementing by one. Let us do it this way. Now we have incremented
the level by one, but we have to make sure we
don't go over the max level. I'm going to make a
new variable called max level and I'm going to
make it as an integer as well. Here you can write
what the max level is. So far in the data table, I can see that my max
level is 11 here. I'm going to write 11
as my max level here. I'm going to drag down and
say if the current level is less or equal
to my max level, then we can go ahead
and spawn the enemy. Because when you
increment the level, you also have to
spawn the next enemy. I'm going to ask here, my current level less or
equal to the max level, we haven't gotten
over the max level. If that is true, I want
to spawn the next enemy. Remember, for the spawn enemy, we already did that in
the play controller. If I go to the play controller, we have this spawn enemy. Let's go ahead and use that. Actually, we use
that here as well. So you can copy this. Or if you want to
remember how you did it, you can take the
player controller. And actually I see we didn't create a variable for this one. Let's just right here, promote this to a variable, call it player controller. And connected and connect this
one with this one instead. Actually, let's
disconnected because now both of them are connected. Hold Alt and click to disconnect and connect just this one. Go ahead and put them
together like this. Now, down here, let's take
the play controller and say spawn enemy connected. Remember we made this
function here called get enemy to spawn
for current level. Basically what that was is we
just got the current level, we got the enemy's name
because it is a new enemy. Because remember we
incremented the level by one. The current level is
incremented by one. It's going to take
the next enemy in the data table, if it was the. It's now going to increment
the level by one. Now it's going to take the Roe, The rogue is going to be
locked into here and spawn. Let's go ahead and here. Now that should work just fine. Let's increment level. We have to run it somewhere. And let's run it
over in the enemy. If I open the enemy again, whenever the enemy dies, just before we destroy the Acta. Let's go ahead and
increment the level. Increment Level is
in the game mode. We already have a reference. Let's take it, let's
say increment. If I can spell here,
increment current level, then we destroy the act. Let's click complain. See what happens if I click on play? I kill the enemy,
the enemy dies. The next spans I can
click again, enemy dies. You can see the death
animations need fixing. And we can do that
in an easy way, but as you can see, everything
is working just fine. And now it looks like a game. Now you can click the
next enemy spawns afterwards and so on. Awesome, Now that is
really good progression. Let us go ahead and
save everything, and let's fix the death
animations in the next one.
47. 5.13 Fixing the Enemy Death Animations: To fix the death animations. Let's go over to the assets
and character us over here. We have to fix them because
there's something wrong with these death animations
if we click on them. Instead of doing it here, I believe we have to
do it in the sprite, open up the textures and
we open up the night, for example, and it's
the death one Death. Open it up, you can
see O point is here, for example, let's
check the night, the night, let's the night is level 11 over
here for the night. I'm just going to set the
health to one actually, I'm just going to
let it be here. I'm going to set my damage. That's a lot easier if I open up the player controller
or the player rather. And the cursor damage. I'm just going to set it to something super high so we can do instant game mode. Let's go to the game mode here. Let's set the current
level to 11 play. I can click here, the enemy
is pushed to the side. This is because the
pivot point is at a wrong place in the pivot point Instead
of center center. You have to change
this one to custom. Now you have to play with
the pivot point here. You can play with it and
you can see what happens. This is the why we don't
need to play with it. One we want to play is this one. Now it is at 24. If I just said it to
custom again, 24, What I want you to
do is say something like minus eight is
usually a good number. Minus eight. You can
see it's the middle. Now try to increment by
eight or say minus eight. Usually for pilot
it goes plus eight. Minus eight, Minus
eight seems to work. We have to do it on all of them. If I open up the assets again, characters, textures, Now I have to do it
for all of them. Instead of doing that
lets me right click, go to Asset Action
It selection in property matrix for the sprite. Let's set the pivot
point to be custom. Now I can't change, for some reason the
custom pivot point here. I have to do it manually. I don't believe we can do it. We have to do it manually. But we set the pivot
point to custom. Now let's click
on the first one. Let's say minus eight, just like before, we have to
do that with all of them. The next one minus eight, the next one minus eight, next one minus eight, and the last one minus eight. Now let's see if
that is working. Let's click on play. Now if we kill this enemy, animation is looking good. I can also see a bug. If you notice if I click on
play and the enemy dies, the enemy spawns
again, disappearing. So you can see the enemy or one frame spawns
before disappearing. Let's go ahead also and
fix that here as well, while we see the bug. Let's go to Blueprint. Let's
go to enemy, enemy base. It's happening here in the
death because we delay it. Then we incremental level and
then we destroy the actor. If you want, you can
take this sprite here, let me just move all of this. We can say here and
say is looping, or set looping rather. Set looping, we can set
the looping to be false. Then you can try
and see here when I kill the enemy to do this. But maybe now it's going to also set the looping to be
false for the next one. Let's actually see what it does. It probably will if I
go to the game mode. Now open up the game mode. Set the current level to
something like nine play. Now if I kill this guy, next one, okay, it is fine. Now everything is working okay. That fixes the problem. Let's go back to the level 11. You can see it fixes
the pivot point, fix the death animation
for this guy. Here you have to test all
of them for level one. Let me just show you a couple of them and I have to
do it on my time, else the video will be too long. But let me just show
you two of them. Is the next one, this one here. Let's go to Textures. Let's find the down
here, the Death. I'm going to select all of them. Right click it. Selection in Property Matrix, in here in the sprite. Let's change the pivot
point to custom. Let's, let's close this down. Now, open up each one here. Now for this one you
can see it's up here. Maybe we have to fix the y and X. I'm going to
say minus eight. It's not minus eight,
it's plus eight. Plus eight, again to
go back to default. And plus eight, again,
maybe I need to. Plus eight again,
like this, it's 48. Let's just try to do this. Plus 16 basically in total. Plus 16, plus 16. I have to guess and see
that is correct over here. Plus 16. 16 for
this one as well. Let's click Play. You can see the death
animation is correct. For the now death is correct. We have to do this for
all of them again. Plus eight minus eight pixels is always the best
option to go with. The next one is the Roe. Let's try the E. You can try
the rest of them yourself. Death we click selection
in Property Matrix. In here, let's go to Sprite. Change the pivot point
or pivot mode to custom. Let's open it up
in the first one again, Let's say plus eight. I think it's plus
eight again. Plus 16. Let's do it for
the rest of them. Let's say plus 16
over here as well. Plus 16, I think is
the same number. Let's copy this
number and basically paste this number on
all of them like this. Just be careful, it's not always the same number in the X. Just pay attention now let's play and see Now the
first death is correct, the second death is correct. Okay, let's do it. I'm going
to do it on my own now. Basically just edit them in the property matrix
to custom and then go ahead and
say plus eight or minus eight until it is fixed. All right, now I am finished. When I click now, you can see whenever
I kill the enemies, they are all fixed regarding
the death animation. So everything is looking good. I'm just going to close it down. Now that was it. Remember to go back to the player controller control the game mode and set
the current level to one if you want. Also set the player
controllers not to play. Control the players cursor
damage to maybe like 15. Again, compile and now we're finished with this and let's move on to the next one.
48. 5.14 Clicking Hit VFX: All right, so what we
can do now is we can do a hit effect whenever we
are hitting the enemy. So we can have some sort
of an effect that appears. So visual effect
whenever we are hitting. Let's go ahead and do that. Now, for the hit effect, I have given you something
inside of the course material. If you open it up over here
in the course materials, I want you to open up the UI. In the UI, I have given
you a hit effect in here. Let's just put it in the images. So let me just
drag it into here. Add it now it is pixel. I'm going to right click right actions and apply
paper to the settings. This is what we will be adding. Just a simple effect for this. Again, this is some
sprites together. Let's just right click like
before and extract sprites. Go ahead and select
Grid over here. For the grid, we have
to guess what it is. Maybe 64 by 64. You can see it is
actually less than that. But what we can do is you
can see it's two by two. So we can actually divide this, we can say divided by
two, or you can write 32. That is fine as well, divided by two and it will be
correct, 32 by 32. Let's go ahead and
extract all of this. Let me just write, click here just so it's not
cluttered with all of this. Let me make a new folder, and I'm going to
call it Textures. And go ahead and
select all of this. And select this as well. And add it into here and here. Let's just make a flip
book out of this one. I select all of this
and I can write Click I can do, quit flip book. Let's call it flip
book. Hit effect. Let's open it up. And this is what it looks like now
for the hit effect. I think the frames per
second by 15 is fine for me. Looks good. We can always
adjust it in the game. Let's close it down for now. And drag this into
the images folder. It is out here, and
we can use it now. You can do this in two ways. The first way you
can do it in is in the blueprint, just like before. Just like the other sprites, you can actually add
the sprite into here. Whenever you click on the enemy, you can play the sprite
so it does some damage. However, the disadvantage
is you can only play one instance of
the damage effect if you click two times
right after each other. It's going to cancel
the last effect and it's going to play the new
one. I don't like that. I want to spawn as
many effect as I want, depending on how
fast the player is. Clicking said, let's go
ahead and the blueprints. And out here, let's right click make a new blueprint class and just make a simple actor that contains this flip book. Crete actor. Let's call
this one BP hit effect. Let's open it up here. Let's add a flip book. If you search for flip book, you can go ahead and add it. I'm just going to
call it Hit Effect. Now we can add the
flip book here. It's this one flip book. Hit Effect. Go ahead
and select it. And here you can see it. Now for this hit effect, I'm just going to go down
to the collision and make sure it doesn't have any collision because
I don't want to, for the collision,
I'm going to remove this one, generate
overlap events. I'm going to say no here
for the collision presets. I'm just going to
say no collision, it doesn't have any
collision whatsoever. I and compile and
let's close it. Now I want to spawn this
whenever I click on the enemy. And remember spawning is always done in the
player control. So I'm just going to go
inside of here for this. I'm just going to make
a new custom event. I'm going to call it spawn
effects just like before, drag here and say
spawn Acta from class. Now, which clause do
we want to spawn? We don't have to connect
it to here because it is just a static value and
it is the hit effect, blueprint we want to spawn here. I'm going to say always
spawn, ignore collisions. Now for the spawn transform, it depends on where we hit with the mouse to find this value. What we can do is we can right click and
use this function. If you just search for mouse, if you don't know what they
are called, that's what I do. Sometimes you can take
a look at all of those. What we can use for this
instance, we can use this one. Convert mouse location
to world space. Wherever the mouse is, we're going to spawn the effect
where the player clicked. Let's go ahead and
do that. Let us connect it here like this. It's going to make it into a transform for us
and connect it. Let's try to do this. For now, we have to spawn
the hit effect somewhere. Let us spawn it inside
of the enemy here. Whenever we click on the enemy
and the enemy is not dead, we apply the damage, but we also want to
play the hit effect. Let's strike here from
the player controller. And we don't really have a reference to the
player controller. Let us do that. Now let me just drag this
game mode over here. Let me say controller. And select it. We have
done this before. We can drag and say, get
player controller reference. We already have that
blueprint interface. Let's rightly can
promote this to a variable called
player controller. Let's go ahead and
connect it here. We have this very quickly. Now we can take this player
controller over here and we say whatever
we called it. If I just go back, I don't
recall, I go back here. We called it spawn hit
effect, drag here. And say spawn hit effect, responding it every
time we apply damage ahead and
compile and save. Now if we just
click on the enemy, see we actually spawn it here. But now you can see it
is looping forever. We have to fix that as well. You also saw that the effect is basically inside
of the enemy. I don't want that as
well to fix that, the effect being
inside of the enemy. This is because, remember
we are working with two D and we're basically
controlling this green value. The green value,
remember it's the y, you move things
behind or in front, instead of it being zero
in the mouse location. Let's just take
this and say plus, let's try to say
plus one in the y. Let's go ahead and
convert it back in here. Play and see plus is
going behind the enemy. If you just delete this
instead and say minus, minus one, go ahead
and connect it again. Play. Now you can see it
is in front of the enemy. Okay, now let's go ahead
and we have to destroy. Because remember it is very important that
you destroy act. Because if you keep clicking, remember we're spawning acts. Just take a look here, how
many actors you're spawning. Every time I click,
I'm spawning an actor. Imagine if you keep
clicking 2 hours later, you're going to
have so many actors that you're going to
crash your own game. Make sure whenever
you spawn something, you also remove it when
you don't need it anymore. Inside of this hit effect
in the begin play, I'm just going to
take this hit effect. This is basically
this flip book here. Now I'm going to say looping
set is looping to be false, I don't want it to loop forever. Also, just like before we
use this flip book length, get the flip book length, and then I'm going to
make a delay node. After the effect has
played one time, I am going to destroy the actor. Which actor am I going to? I'm just going to destroy self, meaning I'm going to destroy
this blueprint here. And when I click play now, and also pay attention to the actors up here,
I click here, I spawn an actor,
but it goes back to 15 and only plays one
time, as you can see here. Even though I spam
here and I click, I do some damage. It looks nice. It will always go back to
15 because it destroys every effect that I create
that is working perfectly. Now let's move on
to the next one.
49. 5.15 Designing the Floating Text UI: Let us now go ahead and
design the floating text UI, which appears whenever
you hit the enemy. And it will say how
much damage you did. Now before we do this,
let me actually just add HP behind the health name. We know it's health. Let's just do that really quickly
before we continue. If you open up your
health bar widget, blueprint that we created
earlier inside of the graph, this is where we
added the health. Now remember, if you want static text besides
some dynamic text, you have to use the
format text very easy. Just write format
text from here. Let's write open curly
brackets and I'm just going to call it health
and close curly bracket. Now this appears, then
we can write space HP. We have HP behind it. And I'm just going to
delete all of this. And we can actually just drag
from here and plug it in, and it's going to use
that integer variable. Now that is fixed and
that is all we had to do. Now you can see if
I click on Play. If I just reorganize
this and click on play. Now you see I also
have HP in the end, and I think it
looks a lot better. Okay, let's close it down. Let's now right click here. Go to User interface
and make a new widget, blueprint. Make a new one. Let's call this
one floating text. Now for this one, let's
open it up once again. Let's add a canvas first.
Then let's add some for the text. We can actually just copy it from
the enemy info. We can use the same one here, control for the text. Go here to the canvas
panel and control V. And here you have it
for the fill screen. I'm going to change it to
desired on screen instead. Then the screen size again, changing it to a laptop
generic like before. Also making sure that
the text here is, it's already because we
copied it from here. But just make sure
the alignment is 0.50 0.5 and the position is 00. It is perfectly
censored into here, and also that the size
to content is ticked. Okay, so here is the text
that we need to have. And that was actually, I mean, there is not really much to it because we're going to
have the damage here. But you can just
write a filler text if you want to, for example. You can write, for example, this is the damage
that the player did. Obviously, the
player is not going to do this much
at the beginning. But again, this
is just a filler. Let's close it down
and let's continue.
50. 5.16 Floating Text Animation: It is now time to do
some UI animation. If you open up your
floating text UI, once again you have the
animation down here. Now if you don't have it open, you can always click down
here and the Animation tab. And then you can click
on Duck in Layout. And it will stay
up all the time. Now to create UI animation, you have to first actually let's just
create the animation. Clicking on the down here, I'm just going to call
it floating text here. First you have to
click on whatever you want to animate this text. For example, this text, I'm actually going to
change the name of it. It's not enemy info, it is floating text like this. You have to click on the
plus track when you do that, and you have the
floating text selected. You can see that it
appears down here. Clicking on the floating text, click over here again. Then we have something
called the transform. And this is where you change
where it is on the screen, as well as the
rotation of the text. If you just open up the
transform and the translation, this is what we want to edit. What I want to do here,
very, very simple. I just want to make this floating text fly upwards
whenever I hit the enemy. So let us get started
here at the zero, It is fine, nothing is going
to happen. It is zero. Now when I go to, let's say 0.6 seconds, I think I'll make
it something like -100 And the y, it is up here. Now you can see
when you drag it, the text flies up. Now you have to test it in game on how quick it actually flies. But if you just click on space, if I just remove these lines here for the floating test text, you can just click
on space to play it. This makes you see how
quick it actually plays. I think it is fine.
We can always adjust it if we
are not satisfied. Now the next thing I want
to do is I want to have it disappeared at this
stage of the animation. And then it appears, and then it
disappears once again up here. Let's click up here. Let's find the opacity down
here, the Rendo opacity. Let's go ahead and click on it. Now at the beginning,
I want it to be zero. It starts with no opacity and then it goes to maybe
something like 15. Here at 15, I want the opacity to be one.
Again, it appears. Now you can see appears, or it appears here for us, it's invisible at the beginning. Then I think at 0.45
I want it to be one. Again, just clicking
on this small dot here to add an animation point. Then at the end here,
I want it to be zero. Once again, you can see
it appears like this. And then it disappears
over here again. Click on the space and see
what the animation looks like. A very simple animation, but it looks professional. Somehow, very quick. You can spend a lot of time, sometimes I spend
like a half an hour, 1 hour, 2 hours to make
something very complex. You can always make the
text not only fly upwards, but it can fly like this in an arch to the side like this. You can try to play with the animation
as much as you want. It always looks professional
when a game has really good. For example, I animation,
text animation. That was all that we had to do now that we have
the animation. Let's continue to the next one.
51. 5.17 Spawning the Floating Text: All right, for floating text, we need to spawn
it into the level. Now, we can't add
it to the enemy, usually we went into the
enemy and inside of here we added a widget like
the health bar and so on. However, for the text, since we are spamming this like we're spamming the enemy and we're
clicking here, a lot of text is going to
appear as combat text. We can't add it to the enemy because if we add
it to the enemy, only one instance of this
text will appear at once. It will look a bit stupid if just one text is flying here, just like the hit effect here. When we click on the enemy, we have to spawn the text
just like what we did here. Remember with the hit effect, we actually attached
it to an actor which spawns and then it
deletes itself later. We have to do the same method. Let's right click here, make a new blueprint class. Just select a simple actor, Let's call this one
BP floating text. Now inside of here,
let's open up this one. For the floating text, let's click on a
Search for Widget. Go ahead and select widget one. Let's just call
it floating text. Now, clicking on it, let's
change the space to screen, because we want it to view it towards the screen
for the widget class. Let's change it to
the floating text. Draw a desired size, then it should be fine. Go ahead and compile the
next thing we want to do. Now remember we need to spawn this whenever
we click the enemy. We let's see here, the enemies and base. Whenever we click the
enemy and apply damage, we want to spawn this actor. Now remember spawning, We are doing it in the
Player Controller. Let's go to the
Player controller, open it up, here we are doing the spawning
inside of here. Let's go ahead and make
a new event for it. Let's right click, make a new
custom event for this one. Let's call it spawn
floating text. Again, we are going to
right click here and use the one called spawn
actor from class. This one, the thing we want
to spawn just like before. We don't need to have it being dynamic like
this into the event because it is just one class aesthetic class
that we're spawning. Just like the hit effect here. We are going to select the floating text that
we want to spawn, then go ahead and connect it. Now where do we
want to spawn it? We need a spawn location, we don't really
need the transform. Instead, I'm going to take
this and say make transform. When we do that, we are
breaking the transform. Remember a trans, if you
look at the details panel, if you select something, it consists of the
location, rotation, and scale of the item
when we break it down. And it's called to
make, remember it's called break if
it goes this way, but it's called,
it goes this way. Can always drag from here. Say break vector for example. But I can't say make
vector this way. This doesn't make sense. Breaking this way,
making this way. We're making the transform. So we can see the location, rotation and the scale as well. Now that we have the location, let's just drag it into
here and see what happens. We can always edit it later. For this, I'm going to
call it spawn location. Then we also need the
text we need to have, what should the text be? Let us just edit that later. We don't have to do it now, but now we are at least spawning
the text also down here. Make sure that you
select always spawn ignore collisions and
go ahead and compile. Let's make sure that the
collisions are not there. If I go to the floating text
and I click on the widget, go down at the bottom character, step up on no, remove, generate overlap events. And also for the
collision presets, set it to no collision. We don't want any collision
from this actor here. Go ahead and save everything. Now over here in the enemy base, let's try to spawn it here
for the play controller. We already have this here. Let's strike and say
spawn floating text. Go ahead and select
now we have to specify a location to
where we want to spawn it. Now where we want to spawn it is just where this
enemy is currently. And remember we
are in the enemy. I'm just going to drag from
here and say get a location. Or getting the enemy's location, I'm just going to
spawn it therefore. Now let's just click on Play
and see what happens if I click on the act here
or on the enemy. You can see that it
is spawning indeed, but we also have to remove it. It doesn't look buggy like this, but let's continue with
that in another lesson. At least now we are spawning the text when
we click on the enemy. As you can see here, we're basically playing this
spawn floating text. What I want to do as well here
for the spawn hit effect, this is basically played
every time we hit the enemy. And we're spawning
the floating text because we're hitting the enemy. What we can do right now, since I don't see any
problem with it currently, we can always spawn the
hit effect inside of here. Every time we do damage, we have to play this and this. I like to play as less functions as possible so you don't
get confused of your game. Later on I'm going to
control X to remove this. Then I'm going to connect
this spawn floating text. Only then I'm going
to go inside of here. Here we can spawn
this hit effect. We already have this
event inside of here. Just drag and say,
spawn hit effect. Now we can always
spawn the hit effect every time we spawn
the floating text. If there is an instance
later in the game where we have to spawn the floating
text without the hit effect, we can always come back
and add it inside of here. But for now we don't really need to add two
events all the time. We can always play this and
everything will be just fine. Okay, that was for now. Let's continue
with the next one.
52. 5.18 Updating the Floating Text Display: Okay, now we are going to update the floating
text correctly. Now you can try
to do it yourself because actually a simple task. So try to think of how can I update this floating
text correctly. When I click on the enemy, this text should be
displayed correctly. It's always nice to do it yourself if you're still a
bit unsure on how to do it. Let's try to continue
together now. I like to sometimes
start in reverse. Instead of starting from the player controller and
trying to update things here. I'd like to start
with the last step, because it's going to make
the most sense in the end. Let's go to the UI. Let's open up the floating text. Basically, the goal we want to do is update this text here. We called it text
floating text and then we made it is variable
here in the graph. Let's just delete all of this. What we want to do
is we just want to take this text and use
the one called set text. This is basically our goal. We want to set the
text to something of the value that's like the
damage we do with the mouse. What we can do is we can right click and do a custom event. And then we can say
update floating text. We can just use
this custom event. Let's go ahead and
connect it now for the text we want
to update it with, we can always just plug
it into the event and we can update later dynamically. Let's just call it text, or you can also call
it floating text. I'm just going to call it text. Actually, we don't
need to call it floating text and compile. Now we need to use this
update, floating text. I'm going to update it through my actor because that's what
makes the most sense for me. Going to the blueprints. Going to the floating text. Open it up inside of here, we want to use this
update, floating text. I, I'm going to use it
whenever we spawn the actor. Every time I click and
we spawn this actor, I want it to be
updated instantly. I'm just going to use the begin. Play here in the floating
text actor here. Let's use this floating text. We added the widget,
let's drag it into here. And say get user widget data. Or get user widget
object rather, not data. Now this one we are going
to say, again, cost two. Let's cost to the floating text over here. Go ahead
and connect it. Now for this one we are going to drag and now we can use the
update floating text, UI. Let's drag and say
update floating text I. We have to have a value
from this text because now you can see if I just
write hello for example. And I compile and I click Play. And I click here, you can see now it is
updating correctly. However, how do I
get the damage here? Because we don't really
have a text variable and I don't really have plug ins
for it like any inputs. Now what you can do is you
can make a new variable. If I make a new variable over here and I just call it text, I'm going to change
it into a string. What we can do now is we can go down and open up the
Player Controller. Remember this is the next step
if we go backwards because in the play controller we
spawn this floating text. Since you made it into
an instance editable and expose on spawn what is going to happen
now if you compile, sometimes doesn't
appear, so you have to click on File and
refresh all nodes. When you do that, you can
see this text appears. This is happening because
you are setting this to an instance Editable
and expose on spawn, which is then making this exposed here When
we spawn the actor. What we can do now
is we can take this text and again,
plug it up here. I'm just going to put it above this spawn location and we can just let it be called text. That is fine. Now if I go
back to the floating text, let me just take this text
here and plug it into here. It's going to
automatically change my text into a string
just like this. Okay, now we are adding it to
the player controller here, so it should appear
in the enemy base. So let's go ahead and check in the enemies open
up the enemy base. And now we can see we
have a text input. Now for the text input, what we simply want to display is the damage of the mouse. And we already
have that. We have that in the player pawn, we have the cursor damage. You can always control C, control V. Copy it here and
just go ahead and connect it. Now it's going to convert your float into a text variable. Okay, that should
actually work perfectly now if we just click on
Play and test it out. If I click my damage
is 15 with a mouse, and that is correct, everything is working correctly. But as you can see, it is still stuck here in the middle because we have to play
with the animation. And we will do that
in the next lesson. But just to go
through it quickly, you can see how we
work backwards and sometimes actually
makes them more sense. Starting with, do you
actually want to do, I want to set my text, and this is where I started. Then I go backwards
and try to do that. And it makes actually more sense sometimes in the animate base we're plugging in
the cursor damage. It goes through to the
spawn floating text, which is in the play controller
responding the actor. And we're plugging
this text information into here which is basically appearing because here we
clicked on the text and made it exposed on spawn
this text information. Now that we have, we're plugging it into the update
floating text UI. And it is going to
update the UI like this. Okay, that was it for now. Let's continue
with the next one.
53. 5.19 Playing the Floating Text Animation: All right, let's go ahead
and play the animation. Let's go back to
the UI and open up the floating text UI inside of here. Let's
go to the graph. In the graph, we see
this floating text anim, which we made earlier
as you can see here. Now for this animation, let's go to the graph.
Let's drag it in. Let's strike from
this animation and simply just say play animation. Now we can use this
function, play animation. Go ahead and connect it Now
for this play animation, that time is zero. That is fine. The amount of times
it's going to loop is one that is
fine for everything. Here is good. We don't really
need to change anything. Now, if I click on
play and click on it, you can see the
animation is playing. Everything is actually working,
and that should be it. However, remember, we are
not destroying the actor. And this is going to
be a huge problem for your game if you don't. Because now you can
see when I click, you can see the amount
of actors I spawn. Right now it is 32, I keep clicking, it is now 42 because we're only
removing the hit effect. Remember, we also spawn
this hit effect right now. And spawning and
spawning actors of the floating text and
we never remove them. That is going to be a problem
and it's going to crash your game if you click
it enough times. Let us open up the
floating text. How do we destroy
this floating text? I, We can actually do
that inside again. Go back to the blueprints, open up the floating text. Let's do it inside of here. Let's, now that we have
this floating text, we can drag and search
for the floating text, floating anim that
we created earlier. Now what we can
do here is we can drag and say get end time. We can use a delay
just like before. You can even open up the hit effect and see what we did here. We basically did the same thing. However, this was a flip book. We got the flip books length. Now for the animation, we're getting the end time. We know when it ends. When you do that,
you can then use a delay after the
animation has played. Once you can go ahead and delete this floating text
actor just right from here. And say destroy actor. And now it's going
to be destroyed. Let us say all.
And click on play. And I'm just going
to minimize this. Again, I can see the amount
of actors I'm spawning. Now I'm clicking,
clicking, and clicking, I should be back
at 15 once again, because I'm deleting all of my text here,
my floating text. I'm going to adjust
the location of the text because I
don't want it to spawn in the middle
of the enemy. I'm going to open up
the Player Controller, and this is where we
have the spawn location. I'm going to drag it out here. Instead, I'm going to
take this and say break vector so I can break
it into an X, Y and Z. Also the same thing
for this one. I'm going to drag and say make vector can see the
x, y, and z as well. Now when you do this, you can always look here
in the viewport and see the axis, the location of it. Now for the x here, we don't really need to modify it because it is
already centered to the actor for the x. I'm just going
to drag it directly in. I don't want to adjust
this value now for the y, Y is this one, the green one. Y controls how much
back and forth it is. I'm just going to say one for the Y here because one
just means I'm just going to put it a bit
in front of the enemy. The text doesn't spawn
into the enemy and we get like a bug visual effect. Instead of ten, here
you can see it's ten. Now instead of I'm going to
just write one in the Y, I'm making sure that this text
is in front of the enemy. For the value now this
is the important one, the Z value is this one. And I wanted to spawn
here up above the enemy. What I can do is I can
say maybe something like taking this Z that we already have and I'm going
to say plus add it. I'm going to add 22 it and then I'm going
to plug it back in. Now what we're doing, basically
we're taking the z value, we're adding 22 it, and then we're plugging it in. Going ahead and playing. I can see where it spans paws
here above the character. I think that is a lot
better than before. You can always
adjust the location depending on where you
want the text to be. Okay, that was it for now. Let's go ahead and
save everything, and let us now continue.
54. 6.01 Designing the Timer UI: All right, now it's
time to add the timer. When we play the game and we're trying to do
damage to this enemy, I want to have a
round timer so you don't have forever
to fill this enemy. If the round timer is over, then this enemy will real. If you do it too slow, it will heal up again and
you have to maybe go back one level to defeat the other enemy before
you can continue. Let's just close
this down for now. Now the timer is going to
be inside of the main UI. It's not really a UI by itself. Let's go ahead and create the
main UI. Let's right click, go to user interfaces
with it, Blueprint. Let's call this one B main. This is the main
UI for the game. Let's open it up
and inside of here, once again at a canvas panel. Now, inside of
this canvas panel, I want the timer to
be horizontally here. I'm just going to find
a horizontal box. Going to add it here. And then this horizontal box, I am going to align
it to the middle, up here, to the top middle. Clicking on the anchor
points, tener, top middle. If you write 00 in the x and y, you can see it's not centered as usual I have here in the x, I have to write 0.5 so
it is in the center now. Okay, so that is finished
now for the image, or for the icon, I'm going
to search for image, Go ahead and add it to
the horizontal box. Now for the icons, we haven't really imported anything yet, and I have included this
for you here in the UI. I have a clock here, fat click, make a new
folder called icons. Let's go ahead and out of here, let's drag this icon in. Just make sure, again,
double click on it, make sure that the texture
group is set to UI and the compression
settings is set to user interface two D.
Go ahead and save. Let's go back inside of
here and search for clock, or it's just here
in front of us now. Instead of making this stretched here for the vertical alignment, I'm going to click
on the middle. Then let us add some text. Now for the text,
I'm just going to copy it from our other UI's. Maybe this one here. I'm going
to control, go back here. Control V on the horizontal box. Center it vertically.
Here we have it. Let us give it some space, let's search for a spacer. Add it in between those. The spacer, maybe I'll
give it something like 12 D X. I think it looks good. Now, the text, we can always
reduce the size. Now for the text, I don't
know if we should reduce the size or not because it's
actually an important timer. I think the size is fine. Let's just increase the size
of this image down here. Instead of 32 by 32, I'm going to write 40 by
40, something like this. You can also give it a
pad to the bottom here. I don't think it's too centered. Maybe if I click here and I give it a padding to the
bottom, something like two. And that should be just fine. We can always adjust it later. I'm not too worried
about the UI right now. You can also click Size
to Content here on the horizontal box to
the top, we can push it. So let's see here
what we can do in the Y. I usually write 30, 35, It's on the edges here. Now this is what it looks
like. I think it looks good. However, for clicker games, I like the clock to be up here. Because it's super
important that you see how much time you
have left when you click. And you don't have
to look all the way up here instead of here. Now, I'm just going
to add it up here. For now, we can
always change the UI. It doesn't take once you have programmed
everything you can actually imagine if
you have a large game, you can actually
change all of the UI. Maybe in one day it's
not going to take long, and this game obviously
doesn't have too much UI. So we can change
it within an hour. But for now, let's just
have the clock be up here. And let's save everything. Let me click on the text, make sure that visibility
is set to not hit testable. This one as well. We can just set it to
hit testable as well, so the mouse doesn't
interact with it. That was it. Let's
save everything, and let us move on
to the next one.
55. 6.02 Displaying the Main UI: Now let's go ahead and display
the main UI to the screen. Usually when we work with UI, we are doing that inside
of the player controller. Let's open up the
player controller and let's do it inside of here. Now, we haven't
done anything with UI where we have
it on the screen. We usually, what we have done so far is having it
attached to an actor, but now we actually
have to create some UI and attached to the screen
instead of to the actor. Let us go ahead and do that.
I'm just going to push all of these down up
here. Let us begin. Now what I usually do is I right click here and
make a custom event. And I'm going to show
you a smart method if you haven't done it already. In one of my other courses, usually I create an
event called show hide or open close widget. Open close widgets, you can
call it whatever you want. Show hide widget, open
close widgit. This is here. Now we have to have an input of what widget are
we talking about? And I don't think
we have created an enumeration for that yet. If you call it Come
blueprints, enumerations. Now, inside of here, I'm
going to make a list of which UI I am going
to have in my game. I'm going to call
it game widgets, because later on I also have one may be called
main menu widgets. So this one is
called game widgets. Now we have to
specify here a list of which widgets do
you have in game. For example, I can
have a main UI. I can, for example, an upgrade shop, and so on. You can have that later, but for now I only need the main UI. I'm just going to call it main. Now if you go back to
the play controller, we can now here in the
input we can search for that enumeration we
called game widgets. And we can go out and select it. I'm just going to call
this one widgets. If we open and close a widget, we have to specify which
widget are we talking about. I can actually call
this function here, or this event, so you can
see what it looks like. This is what it will look like when I call this function later. Now we can select which
widgit are we talking about. Also, I want another
input, a bull. A bullion is simply,
again, just a yes or no. Just a false or true. For this one, I'm
going to say open, I'm just going to call it show. I like to usually
call it show hide. I don't confuse
myself for this one. I'm going to rename it
to Show Hide Widgets. We have to specify which widget are we talking about for now. We just have the main UI and
then we can show or hide it. If I have that
unticked, it's hide. And if I have that
ticked, it's show. This is how I usually do it. This one, we can make a branch. Now if it is show, we want to show the widget. Because this is true. Let's make two functions. Let me make one called
show widget and make another one widget. Usually I add an for my
functions as a prefix. It's a lot easier to search for because if you right click
and you actually search, then you can have all of your
functions in the future. For the show widgets,
I'm going to click, I have an input of game widgets and select
that and call it widget. The same thing here
for the hyde Widgit, go ahead and click
on it, add this, and call it widget. What we want to do here
now in the show Widgit, we want to drag from here and
say switch on enumeration. What we're going to do
here, we're basically telling it if the enumeration, or if this value is main,
what do we want to do? Imagine if we had another
one, for example, if we had a Settings menu
and go out and Save. Now you can see here,
this is being added here. If the value that
comes through here, which is basically
selected from up here, we select what the value should be if it goes here
into the show widget. And the value is
main, for example, it's going to ignore
the code down here, and it's only going to
run the code up here. This is what switch
on enumeration. Is the code right
here going to run? And this one is not going to run if the value
is main over here. Let me just delete
this settings for now. What we want to do
here is basically create the widget and
add it to the screen. Let's right click and say create widgets que selected select which widget
you want to create. I want to create the
main UI and right click, promote that to a variable. Let's call it basically
the main widget. Then what we want to
do is drag from here and say Add to Viewport. This is how we add
the UI to the screen, because it's not enough
that you created, but you also have to add it to the viewport before
you can see it, okay. Now we can connect it like this, and everything is good. However, what I like to do is just for optimization's sake, we can take this variable
we just created, we can write click and
convert to a validated get. What we can do now is let's just disconnect this by holding Alt and clicking and
we can connect this. Now if this is not valid, this variable is not valid. This means that this has
not been created yet. We haven't created the UI yet. It will say not valid. When it is not valid, we want to go ahead
and create the UI. However, if we already created the UI once before
it will be valid, we don't have to create
this all the time and keep setting this variable if we have already done
it once before, it will be valid if
we have done it once. And then I will just go ahead and add it to the
viewpoint instead, we don't have to create
it all the time. Okay, let's compile now
for the Hyde widget. Let's go back here the same. Let's say switch on enumeration, switch on game widgets. Then here what I want you to do, simply just drag this variable, right click again, convert to a validated get,
just like before. Then let's drag and say
remove from parents. Removing it from the screen. This is removed from parents, now we're removing
it from the screen. Okay, how do we use these
functions we just created? Now, if we go back
to the event graph, we can drag in the functions, the show and hide widget. Let's go ahead and connect them. If the bullying is true, we want to show the widget, we go ahead and
connect this one. If this is false, we want to hide the widget, we connect the other one. Now, for the widget that goes in is simply what we
have selected up here. But we can just drag this
input into those functions, and the data will go on
into these functions here. Now it is actually finished. What we can do is
we can, we can call this event here whenever we want to show
and hide a widget. So I can say show, hide widget. I can specify which
widget I'm talking about. I can also specify if we want to show or hide that widget. Super smart function
that we can use. This is basically,
so we don't have to write all of
this code out here, it is a lot easier to
just use this one. Let's go ahead and
display the main UI. Let's just do that here
in the Player Controller. Let's write events, begin play. What should happen when I
begin playing the game? I just want to show
hide this widget. So I want to show my main
menu, or my main UI. Basically. This is it here. If we compile and
I click on play, you can see I can now
see my timer up here. Because now we are
showing the widget. If you want to hide the widget, you can always click over here. And you can click on play. And you can see the
widget is gone, because now we're hiding it. Showing the main widget, and that is how it's done. Let's go ahead and close
everything, and let's continue.
56. 6.03 Setting the Round Timer: It is now time to
add the round timer. Now, inside of
single player games, we are not really held accountable to where we
want to add the code. I could add the round
timer to the player, I could add it to the
player controller, and I could add it
to the game mode. Basically, in multiplayer,
you would have a problem, because you would have
to do things correctly. But in single player, we can
actually code everything, for example, inside
of the player, even though it should
be in the game mode. And the game would
function just fine to just stay and do good
programming practice. Let's do the round timer
inside of the game mode. Remember the game mode controls
the rules of the game. I think something
like a round timer is something of a rule in a game. Instead of here, let's
do the round timer. I want to do is let's try
to do another custom event. Let's right click and
do a custom event. Let's call this one
start round timer. We want to start
the round timer. I want to use here mainly something
called timer by event. Far right click and
search timer by event, select that one. Now the timer by event is simply a timer that loops
over and over again. Instead of using the event tick, maybe you know what an
event tick is already. If you don't, this one is
running 60 times per second. If I can just drag here and print a string and
just say hello. You can see if I click Play, it's actually going to
print 60 times a second. Here it says hello. Usually this is very bad to use in a game. If I some day look at your game, I never want to see an event tick in your game
because this is super bad to use unless you absolutely
have to use it actually. For Fun Tail, I
developed for two years, I have never used this one. And I don't think you should
use it either because it's really optimized to run
this code this many times. Instead, we do this by
setting up a timer. A timer, you can choose how many times you
want to loop it a second instead of looping
it 60 times a second. What I can write here
is, for example, 0.1 If you're not
really good at math, what you can do here is
you can basically say, what is 1/0 0.1 That is ten. This means that it runs
ten times a second. What if I set it to 0.03 Then you are going to run
it 33 times per second. Now sometimes you have to do it this many times
because for example, in an RTS game where you build buildings just like The Sims, for example, in the Sims you
drag a building or an item, you can place it around. Now to update that
building ghost that you're dragging around, it is very important
that it looks smooth. You have to set it to something
like 0.03 for example. But you can see running
it 33 times per second is a lot better than
running it 60 1 second. You're running it basically
half the speed of this one. And it's already
going to be a lot optimized just by you using
a timer and doing this here. For example, for
the timer by event, we don't really need
to update the Tim. For example, 33 times a second. We can start with
something like 0.1 We can basically update the
timer ten times a second. Let's try and do that. Let's delete this down here. Let's connect this one up here. For the event here, we
have to have an event. I can drag down here, make a custom event. I usually just call
it loop in the end, so I'm just going to call
it round timer, loop. This event here is
basically going to loop. We're going to set
it to is looping. What I want to do is I
basically want to set a timer. Let's create two variables. Let me create one called
initial round timer. Let's set it to float, compile. Now this is going to be
our initial round timer. Let's for example, say we have 5 seconds initially
to kill this enemy. Let's make a new one
called Current Round Tim. This is the one that's
going to be updated. The initial round timer
is not going to change, but we're going to change our
current round timer first. Before we start this loop here, let's make sure that
the current round timer is equal to the
initial round timer, else it will be zero. You don't want to
start it looping with the time being zero. Let's set the current round
timer to the initial one. Like this, now we have
some time to begin with. The time is 5 seconds, because we've set
this one to be five, now this one is 5 seconds. What we want to do here, we want to take the
current round timer. I want to say minus. We basically want
to subtract it with 0.1 If this is going to
run ten times a second, what this means is it's
going to say it's basically going to remove 1 second every second, if
that makes sense. Because this is going to run ten times instead of
having a static value. Again, I don't like
static values because it's a pain to change if
the game gets lodged. Instead, you can right click this value and promote
it to a variable, and you can call it something
like round timer time. I hope it doesn't get too confusing or confuses
me in the future, because this is the round timer, this is basically the time here. Let's just drag it into here. Instead of having
this static value, this -0.1 let's compile
and make sure that the round timer time
is 0.1 Also up here. Let's right click this timer and promote this to a variable, because later on we have to stop this timer if we don't
want to use it anymore. And we do that by
having this variable. Let's call this one Tim Handle. If you hold the mouse over it, it's basically a timer
handle, round timer handle. Now what we can do is
now we're saying this current time -0.1 Again, I have to clamp it
because I want to make sure it is not going
to be beneath zero. Now what we're saying
is the current timer, round timer -0.1
If we loop that, this amount as well,
it's basically going to minus one every second. I'm going to set the
current round timer again, we're basically saying
minus one every second. Now let's go ahead
and print a string. You can actually
see what's going on and let's drag this into here. Let us comp the round. Tim can basically just start it up here in the event begin play. Let's just strike from here
and say start round Tim. Let's compile and play. Now you can see that
timer is working now. It's going to go beneath the zero because we
haven't clamped it. Let's actually go
ahead and do that. Let's strike here again. Drag from here and
say clamplamp float, The minimum value is
zero beneath zero. The maximum value is what the current round
timer is basically. Now let us go ahead
and connect this. Everything should be just fine if I compile
and click on Play. And take a look up here now, it shouldn't go beneath zero, and everything is
working just fine. Now we just have to update this UI up here to
work correctly. All right, that was it for now. We have a functioning timer, and we can just
let this be here, because we have to
start the timer, everything is working well. And we have to continue
in the next lesson.
57. 6.04 Updating the Main UI Timer: All right, here is
where we left off. Let's go back and update
the timer in the main UI. What we want to do is we want
to go back to the main UI. We want to click on this text. Let's call it something
like round timer. Round timer. Let's go back to the graph here. Let me just delete all of this. Now for this timer, I
basically want to, again, set text, just what we
have been doing so far. Let's make a custom event for this custom event.
Let's call this one update, Tim. I let us just
go ahead and connect it. Now for this, let's go ahead and instead of just
connecting it directly, I wanted to say seconds
behind it as well. I want to use a format text, just like what we have
been doing so far. For this format text,
I want a variable. Let's just call it
round timer remaining. Let's close the curly brackets. And if you hit inter,
this input appears, then I just want to
write sec behind it. We know it's seconds. Now this variable is a float. I'm just going to
here add an input of float and call it
round timer remaining. Now we can go ahead
and plug this into here and we are
basically finished. Now let's go ahead
and update it. Let's use this update timer UI. Now you can try to do it
yourself just for practice because it's actually simple
if you just think about it. But if you still have
difficulties with it, let's go ahead and
do it together. If we go back to the blueprints, open up the mode where
we made the code. Now here, whenever
it is looping, we also want to update the UI. After we set the round timer, we want to update the UI. Now, how do we get the UI? Remember, the UI is inside of the main here,
the main widget. This is the event
we want to use. We have to get a
variable or the main UI. Remember, we already have this inside of the
player controller, because inside of here we
made this in a variable. Let's go ahead and called
the player controller. Do we have a variable to the
play controller? Yes we do. We did this previously. Let's go ahead and drag
in the player controller. Let's drag in WB
main and get that. Then let's get the update timer UI events. We can call this now
let's connect it. Now this is the round timer
remaining, which is this. Basically, let us compile. And if I click on play, now you can see it is
working just fine. Now you can see
there is a problem because I don't want to remove this decimal place
whenever it is zero. Like this, I wanted to
say 0.0 for example, or 1.0 I don't want
it to remove it. The way you do this, instead of directly plugging in the float, you can actually convert
it to a string first and it will not delete
whatever you are writing, you just write two string. Go ahead and select
two string float. Now instead of having a
float, let's disconnect this. And let's plug in the string. Let's compile. Let's
click on Play. And now you can see it
says zero in the end, and it's not going to delete it. I think it looks a
lot better for us, that was it for updating the UI. And let's move on
to the next lesson.
58. 6.05 Restore Health on Timer End: The main goal here is to restore the enemy health whenever
the timer has run out. Let's do that.
This is very easy. We already have whatever we need here in the
start round timer. Whenever we loop through the
time and it gets to zero. Let's take the round timer
here and we can basically just take a new variable instead of using this
one all the time. Just to make it more clean,
we can use this one. And now we can say if
this is equal zero, so basically the
time has run out, let's make a branch, let's
go ahead and connect it. Whenever this is the case, we want to restore the health, let's go ahead and
make the custom event for the restore health. And I think it's best to do
that inside of the enemy. Let's go over to the enemy, open up the enemy
base inside of here. Let's create one
called restore health. Let's go down here, make
a new custom event. Let's call it restore
health like this. Now for the restore health, what we're simply going to do, remember previously we have this one called update health. We can basically just use that one I drag here
and say update health. Update health, here it is. Now what is the current health? We just want to heal the
enemy to the maximum. Again, again we have the get enemy info and we
already have the health. I'm going to control C this
and control V down here. We're just going to
plug this into here. We're basically
restoring the health. Once again, that should be it. If I go back to the game mode, now we need a variable
to the enemy. I don't remember if
we have a variable to the enemy inside
of here, we don't. We have to figure out how do we get the variable for the enemy? Because we need to call
this restore health. Remember, if we go
back to, for example, the Player Controller,
this is where we spawned the
enemy, spawn enemy. And we made it into a variable. We actually know which
enemy is spawned currently. If I go back here and I take
the Player Controller and I can search for the
spawned enemy variable, and I can take this. Now here we can say
restore health. I can see I cannot find it. So if I go back to the
Player Controller, this is because I
directly promoted this one to the spawn
enemy variable. Which is not wrong. I
can basically go to the game mode and says to enemy base here I can say restore health and
everything will be just fine. But again, I don't
like to use casting. And this part is
also unnecessary because we can do it inside of the player controller here before we promote
it into a variable. Let's go back to the interfaces. And we haven't done one for the enemy. Try to
do it yourself. We already did it
a couple of times. Again, if you don't
remember fully, let's go ahead and
do it together. Again, I'm going to
go fast through this. Right click blueprint and
create a blueprint interface. Call it enemy base. Go ahead and open it up. Let's say get enemy reference. Then here in the output, let's search for
the BP enemy base which we are trying
to reference to. Let's call it enemy compile. Now let's go back
to the enemy base. And inside of here in
the class settings, we want to add this
interface we just created, called enemy but compile. Now we can see this function appearing double click on it. For the enemy, I'm going to make a self reference
because again we are inside of the enemy base and we're defining what
this variable is. Now what we can do is in
the player controller, instead of promoting this
directly to a variable, I'll delete this for now. I can say get enemy reference. Because remember if you
hold the mouse over it, this is just an actor reference. But if I promote
this to a variable, this is an enemy base reference. And we can use that
without doing this all the time in all of
the other blueprints. I'm going to remove
this spawned enemy. Let's just actually make sure that we haven't used it before. Because if I delete it now, I'm going to delete all
the references with it. What I usually do in my
games, I right click on it, find references, no results
inside of this blueprint. We have to search globally. You can do that by clicking
on the small icon. It's going to search
in all blueprints. And you can see you have never
used this variable before. It is safe to delete it. I'm going to delete it, yes. Now let's promote this one
to a variable spawned enemy. Now we can use this
one. Let's compile. Let's go back to the game mode.
Let's delete all of this. Now here from the
spawned enemy drag. Let's spawned enemy
from this one. We can now drag and
say restore health. That is a lot easier to do. Let us now drag from here. If the timer is equal to zero, we want to restore the health. We also want to reset the timer because we
have to start again. I'm going to take the current
round timer and set it to the initial run timer
again. Just like this. Let's go ahead and play
and see what happens. Click on Play Now I'll just, so we can test better, I'm going to set the initial
round timers to 3 seconds, so it doesn't take forever. When the timer is gone, it's going to reset, heal. The player now click
or heal the enemy. Rather we can see that it did heal the enemy
whenever it's zero, if I kill the enemy, going
to heal that enemy as well. So what we basically
have to tell it is if I kill the enemy, I have to tell it that stop the timer because now we
have killed the enemy. Because as you can see here,
whenever I kill this enemy, it's not going to stop
or reset the timer. So this is the next thing
we want to work on.
59. 6.06 Reset Timer on Enemy Death: Now what we want to
do is we want to reset this timer
whenever the enemy dies. Let's go ahead and
do that again, this is super easy now
because we already created this variable
called round timer handle. If I go to the enemy base and I try to find where
the enemy died, here we made this death event and we did all of this here. Let us stop the timer
whenever the player or the enemy did all of this. If I can just select all of
it and we can drag it over. Now let's take this handle which is inside
of the game mode. I can see we already have
a game mode variable here, so we can say Tim handle. We can go ahead and get
that run timer handle. We can say clear and
invalidate timer by handle. This one is going to stop the timer clear and
invalidate the timer. Go ahead and connect it. Now we are stopping the timer
and then we're doing all of this death event or
this death logic. Then after the death logic, we're incrementing the level. And then we're
destroying the Acta. We have to start
the timer again, because now when
we kill the enemy, the timer is going to stop. But we have to start it again. I think the best way
to start it again, let's do that inside of the
increment current level. Let's go ahead and do that
inside of the game mode because every time we
increment a level, we spawn an enemy. Let's just start the timer here. It makes the most sense. What we can do is basically,
just like before, we can do this, Start
timer, start round timer. Just go ahead and call
this event that we made. And that should fix everything. Now every time I
don't call the enemy, the enemy is going to
heal, as you can see here. But if I kill the enemy, the timer is going to stop
and then it's going to reset again once
I kill the enemy. So if I kill the enemy,
it's going to reset back to three and everything is great. Okay, so now we are resetting the timer
when the enemy dies. And we're also stopping it
so it doesn't count down. And let us move on
to the next one.
60. 7.01 Designing the Currency UI: It is now time to
design the currency UI. And before we do that, go
to your course materials. And I have included
some things for you. So let's go to the UI
folder right here. I'm going to create
a folder called buttons instead of this folder. We can drag these
buttons into here. Button small pressed
and button small. Go ahead and drag them in. Just like before. Remember
to right click on them sprite actions and apply paper two T because
they are picks a lot. Also for the images in the
images folder I'm going to drag to into here
like this again, I'm going to right click and
apply paper to settings. Now for the clock, I want
to update it as well. It probably looks like
this for you right now. I'm just going to
drag this into here. Or maybe right click
and say re import. It already knows
what it looks like if I click on play,
now looks like this. Let's see if we need something
more, This coin here. We also need in the
icons, drag that in. Right click, Apply paper to settings and everything
should be just fine. Now, before I continue just
checking on this clock, clicking on it, I'm
actually going to increase the size
of it to 50, 50. Instead, the padding is zero. I'm going to set it to zero. Compile, and if I click Play, I think it looks a lot better like this compared to before. All right, now for
the Curren UI, we are going to design it
here inside of the main UI. And I think I'll design
it up here to the top. Let's get started with that. First, we need an overlay. Let's add the overlay into
the canvas panel up here, so it appears up here. Now for this overlay,
I want an image, I want the background
image for this UI. I am going to align it horizontally and
vertically, all the way. Now we have to select what the image should look
like for the image. We are going to go to images, and I am going to select
this one item frame. Go ahead and drop it
in. And here it is now to make it non blurry
again, just like before, change it into a box, change the margin into 0.5, Now it looks a lot better. Now when you change
the overlay size, it fits with the size. Now down here, I also
want an upgrade menu. Or not an upgrade menu, it's more like a store. Let's actually do that as well. Here with it, we need a vertical box. I'm
going to add that in. I'm going to add overlay. Remember that the
vertical box should not be inside of
this horizontal box, it's just outside this overlay. I'm going to drag it into
the vertical box here. Just resizing it. Again,
the overlay again, I'm going to click
on bill for now. I'm not sure if I'm
going to fill it. Actually, I don't think I will. But let's just set
it to fill for now. Let's now add the other one. Again, I'm going to just duplicate this,
Overlay control D. Now this is the upgrade menu, or the shop here, the store. Clicking on the
image, I'm going to change it to this
one paper frame. Go ahead and drag that in here. Everything should be just fine. Now for this vertical box, I wanted to fill the
whole screen to the side. Clicking on the anchor point, changing it to this one. When you do that,
the offset bottom, I'm going to write 00. And the offset for
the bottom and top, it will make this whole
side of the screen filled. Now I'm going to give it
some space from the edges of the screen in the position for the X. I'm going to
write 30 offset, top 30 offset,
bottom 30 as well. Now it is not on the
edge of the screen. Now the size of the two. I'm going to click
on the overlay for the currency and I'm
going to set it to auto. Instead, I'm going
instead here in the images and increasing
the size in the Y. Now for the size in the Y, I think something like
105 should be sufficient. Something like this, and we can write how many coins you have. Also, let's add a spacer
search for a spacer. Add it between these two
overlays for the space. I think I'm going to write
something like 20 in the Y. And you can click
on these dash lines to remove the dash lines. And now this is
what it looks like. You can click on Play
and also watch it. Here you can see this is
a screen for a laptop, but it fits really nicely as
well for my four K monitor, because again, we have designed it to be on multiple monitors. Now for the size here, we will decide this
later depending on the content
inside of this menu. But for now, let's just let it be to the size of
this one up here. Let's with the currency. Right now, we can
work with the store. Up here with the currency, we need a horizontal
box because we need an image and then the text. Let's add it into the overlay inside of this horizontal box. I'm going to add an image, then I'm going to add some text. Now for the text, I'm just
going to copy this up here. Control C Control inside of this horizontal
box. Control V here. Now for this horizontal box, I'm going to align it virtually horizontally in the
middle for this image, let's change it into
this coin icon. We dragged in again, horizontal alignment
and vertical alignment in the
middle. Both of them. Now for the coin here, let's
click on the coin and make the size 50 by 50 for the image. Now for this text,
I'm going to make it a bit larger because
this is very important. I think something like 34 and maybe a bit
lower, maybe 30. We can always decide that later. Now for the front color, I'm also going to change
it to something yellow. It's displaying coins, changing
the color and opacity. I'll try to choose
a yellow color. I think I'll go with
something like this. Now, I also need to
change the outline. I think I'll just copy this one up here.
Paste it down here. I'm just going to change
it to a darker color. I'm going to use this one. Clicking on okay, I'm
going to copy this. Paste it down here.
If I zoom out, this is what it looks like. It looks really nice. Now, I'm going to give
you some padding between the coin and this, this text. Just make sure you have no
padding here for this coin. I'm going to give it a padding
here to the right of four. So we have some
spacing from the text. If I click here, and I'm
just going to write zero for the text, right now it's 30. If I write 28, I think it's too
small. Let's try 32. Maybe it's too large. Let's actually go with 34. Now, 30 was a good number. Let's compile now. Now we have
designed everything here. Now for the text, I'm
going to change it into text mount of coins. For this icon, we don't really
need to do anything here. Let's just compile
and save everything. Now we are ready to continue.
61. 7.02 Currency UI Animation: I think it will be cool
to add some animation to this text to make the game look a bit more
unique and better. And it's always nice to add some animations to your game
so it doesn't look flat. It's always these
small details that makes your game look a lot
better than the other ones. So let's go ahead and
click on this one. We're going to create
a new animation. We're just going
to call it coins. Click on it, click on Track, add the text amount of coins, and click on this plus. And let's select the transform. Because I want to change
the scale of this text. Going to the scale down here. What I want to do here
is after 0.2 seconds, I want to scale this up to 1.5 The same thing
here for the Y, 1.5 Now it's huge. Then 0.4 I'm going to set it
back to 1.1 in the scale. Now you can see when I play the animation, it
didn't actually set it. Here I go, back set to one, I play the animation. Now you can see what it looks like if you
just click space. This is what it's going
to look like when I add coins to this variable
or this UI here. It looks nice that you
have some UI animation. But then compile,
save everything, and let us continue.
62. 7.03 Amount Of Coins Variable: Now for the amount of coins we need to add that to the player. Let's go back to the blueprints. And now let's open up the
player because now we need to store how many coins the
player has in a variable. Let's just make this variable
down here and let's make it amount of coins,
let's call it that. The amount of coins cannot
have decimal places, so we're just going
to choose an integer. Now if you know your game is going to be hue in numbers here, you have to select
an integer 64. I actually think I am going
to select an integer 64 because an integer or an
integer 64 can have a much, much larger value
than an integer. However, again, an integer
64 is going to optimization wise be heavier than
using just an integer. But we really need that because again we are creating
a clicker game. And it is known in
a clicker game that the amount of coins can
get into an intense value. Go ahead and select the
integer 64 instead. Let's make it like this. Now I'm going to delete all
of this and let's just make a new custom variable
or custom events. Let's call this one
update amount of coins. We're going to update how
many coins we have here. I'm going to drag it
in the Set it here, the update amount of coins. We can give it two variables. We can give it the
amount of coins we want to update it
with amount of coins. This one can be an
integer because this is just a number that we need to plus or minus with our variable. It isn't that huge. The other thing is let's add another variable and a bullion, let's call it a I usually
again, write B in the front. What we want to do
here is do we want to add coins or do we want
to subtract coins? This is what this
event is about. Let's strike this one
and make a branch. Then let's, do you want to add coins or do you want
to remove coins? So this is the falls. When
you want to remove coins, let's set this variable. If we want to add coins,
we can take this. We can say loss this amount, loss this integer, I
can drag that in now, we can take this and
set it into here. The amount that
goes in here loss the amount that we already
have in the variable. We add these two together and we set them
inside of this variable. Now if it is minus, again take this and say minus, subtract, we're
going to subtract it from here. Just like before. We're going to set
this variable. Now you can make this code a bit cleaner by actually
removing this. And you can do it
in another way. Now I'm going to show
you just another way. Remember we have worked
with Select before, so we can actually do Select. Now, every time you see a
copy paste of code like this, you always try to think, can I use a select node
here to clean my code? You can actually do that
here if I drag here and say Select and I can
select this one, this node depending on if this
bulling is true or false. And I can just
remove this for now. If it is true, means I want to add coins. You can see here,
if this is true, here means I want to add
the amount of coins. So this one is true, I want to add coins. We can plug this into here. This one, if it is false, I want to subtract coins. And then it goes into
here. We can delete this. Now You can see how
much better it got. It knows now from the
bullion if we want to subtract or add coins
to our variable. All right, let's compile and save everything.
And that was it. Now we have this simple
function where we can update the amount of coins.
And let us continue.
63. 7.04 Add Coins Drop To Enemies: Now obviously what
we're trying to do is when I click on this
enemy and the enemy dies, I need to get coins for the
kill that I have killed here. What we need to do
is we need to add how many coins should this enemy drop when
I killed the enemy. The way we do this,
remember we have a structure here in the
blueprints structures. We already made this
one called enemy info. Let's just add something
to it, to this one. I'm going to make a new
variable and call it a of coins to drop. Very, very self explanatory
and it's just an integer. And drag it, so I'm just going to drag it beneath the health. Go ahead and save,
save everything. Now what I want you to do is
go back to the data sheet in Google that we made
earlier inside of here. Now after the health,
I'm going to write Click Make a new column
to the right here. Again, you have to call it
the same name that you call the variable amount
of coins to drop. We can drag this
a bit like this. We have to specify how many
coins should the enemy drop. For example, I can just
write random numbers. For now, honestly we don't
really care right now. We can click on this
to make formulas. You can always write
equal. Click on this and times 1.5 Then I can click here and drag it
down and it should auto fill. This should be fine
for me right now. I'm going to click on File
Download and download CSV. Now with this
downloaded CSV file, I'm going to rename it once
again to DT enemy info here. Inside of this project,
I'm just going to minimize it a bit so I
can see both of them. I'm going to go to
the data tables. Again, enemy info, just
click and drag it into here. And it should automatically update all of this
information for you. Now we have added how many coins each enemy should drop
when we kill them.
64. 7.05 Update the Coins Display: Now we are ready to finish
this coins display. Let's go back to the enemies. Now, what I want to do
here in the enemies, remember we want to add it
to when the enemy dies. If I go to this code here, whenever you add extra inputs to your structure,
they will appear. So I'm just going to click here and hide unconnected pins. Once again, when
I kill the enemy. I want to remember
in the player, if I go to the player, we made this one
update amount of coins inside of here
when I kill the enemy. Before I do this delay, I'm just going to
move this delay. I want to call this
one update amount of coins from the player. And I already have
the player variable. I'm going to drag and say
update amount of coins. Go ahead and connect
it here and here. Now the amount of coins
you want to update it with is inside of
the yet enemy info. Because we did that
inside of the library. Now we have to specify the
enemy info or the enemy name. We already have that
from this variable. So go ahead and connect it. Take this break it into the
variables so we can see them. Now from here I'm going to drag the amount of
coins into here. Go ahead and hide this, and now it is finished. Remember to click on Ad. Because we want to add
coins and not remove them. Everything should be just
fine. Go ahead and compile. Go to the player now. Now this information
is going to go in here and it's going
to set this correctly. What we're missing right
now is you can see if I kill the enemy,
nothing is happening. Because remember, we did not update the UI, so
we need to do that. Let's go back to the UI, open the main UI. Go ahead
and click on this text. For this text, we
just want to set it. I'm going to the graph here. Let's make a new event. Let's make a new custom event. And let's call it
updates amount I. Now for this event,
let's click on it. And let's make a new variable
for this one, again, integer 64, because
we're going to plug in this information here
so we can update the UI. And let's call it
amount of points one. Now the goal here is
to set this text, the amount of coins drag in
from this and say set text. This is basically what
we're trying to do. We're trying to update the text and click and drag
this into here. And it should automatically
convert your integer into text and compile
this or plug this in. Now remember we also
have an animation. Let's drag this coins animation. And let's say play animation. Go ahead and plug
that in as well. Everything should be just fine. Now let's go back to the player or use this one.
Update coins amount. I go ahead here and we just need to edit Here it is
inside of the WB main, which is inside of the
player controller. And as I can see here, we don't have a variable for
the player controller. Let's right here in the begin. Play once again. Get get player controller
and get this one. Then we can drag from
here and say get player controller reference that we did from the
blueprint interface. And right click
promote this variable and call it player controller. Now we have this. Let's
take this variable. We just need to call WB main because the
event is inside of it. The less drag and
search for WB main, we already have that value. Remember then we can drag here, say update points amount. I go ahead and select this and block this
information into here. And everything should
work just fine. Now I'm just going to increase
here in the game mode, I'm just going to increase
the initial round timer, because sometimes it's difficult to kill the enemy
within 3 seconds. I'm just going to
increase it to 5 seconds, actually. Yeah, 5 seconds. Fine, Right, And play. Now you can kill this enemy. As you can see the
animation plate. And it gave us 15 coins. Let me just try it again. Here, I'm going to
kill this enemy. It gave us the coins. It played the animation, and everything is
working correctly.
65. 8.01 Adding the Shop Scroll Box: Now it is time to work
with the item shop. If you click on Play, you
remember here in the Ui, after we did the
currency or before, actually we created
this paper down here, this will be our item shop. I'm just trying to mix cookie
Clicker and Clicker heroes. As you can see
here, for example, just an image of what we are doing is we're just
adding this part here, this shop where you can buy some things and they spawn
into the map and so on. So this is what we're
trying to do here. Let's close it down for now. Let's go to the UI
and open up the Maui. And inside of here,
this is where we want the items to display. Now to make them display, we need a scroll box. Let's search for a
scroll box up here. Click and drag it into the
overlay it's inside of here. Also make sure that it is
horizontally and vertically aligned inside of
the scroll box. Before we add the items, we need them inside
of a vertical box. Because they're going
to go down like this. I'm just going to
take a vertical box, add it into the scroll box. For this vertical box, go ahead and click on Fill. Else it's going to be up here. But we want to fill
it all the way here. Now this one is ready. Now you can see here,
whenever I add an item, now it's going to be a, the top here. And we need to give it some
spacing to the edges. Now we can't really do that because I can just
go in here and write 100 and I can give it some
spacing from the edges, but I can't really visualize
it without my item cuts. I'm going to do this
later. I'm just going to write zero for now. This was it for now. Now
this vertical box here, I'm just going to rename it because we're going
to use it later. I'm going to call the VB for vertical box and let's call
it something like item list. Let's set it as variable
because we need to add something or we need to add the items later to
this item list. That was it. Let's close this down and let's continue
with the next one.
66. 8.02 Designing the Shop Item Card: All right, so now it is time
to design the item cards. Now, we are not going to add the item cards
into this main UI, because the items
you can imagine, each item card has unique
information to it. So I'm not going inside
of here and adding a text and then adding the
text to here and so on, because this will be a lot of copy pasting work and
it doesn't make sense. We, basically, what we do for shops in programming is
you take the item card, you design one instance of it, then you dynamically change all the information and
the item code with code, and you just duplicate
this item Cod and change the
information there. Let's try to do it so we
can understand better. Let's close this down here. Let's right click again, Make a new Git blueprints. Let's call this one
shop it code here. Let's open it up.
Now, here again, let's add a canvas. By the way, what we're designing
is something like this. But basically this is what
we're trying to design. It's always nice to see
before we get started, this is what we're
trying to design. You can try to do it
yourself if you wish to. We are doing the
desired on screen. Try to do it yourself
if you wish. Or we can do it together here, adding a canvas first, then going ahead and
adding an overlay, because we need a background
adding the overlay. Clicking on here, let's
add an image as well. This will be our background. Now for this image I'm, let's see here.
Let's go to images. I'm going to use
this one. Drag it in again just like before. Change it to draw box
right in the margin 0.5 Now this overlay here, I'm going to align it in the
middle, the anchor point. And writing 0.5 in the
alignment just like before. Because we want to center it, remember we want to write 00 in the x and y. I'm just
going to click here. Or size to content here, so it's in the middle
here, precisely. Now for the screen size, we are going again to
select desired On screen, it stays with the screen
we have selected. The difference is if
you select desired, you can see here, however, if I go to the screen
size just like before to scale it to my laptop, clicking here, you can see it changes automatically
to desired on screen. Here it is. It is
super, super small. We need to increase the
size of this image. Now, I might not change the image itself because it is
sizing to the content here. I'm just going to add
some content to it and see if it will look good. To begin with, we need
a horizontal box. Let's drag that
into the Overallay. Then in the horizontal
box, we need some text. Now for the text, I'm
just going to copy paste something we already did so
we don't have to redo it. I'm just going to go into
the floating text and I'm going to copy this
text going into here. I'm going to paste it
into the horizontal box. For this image, I can
see it's not scaling properly in the
horizontal alignment and vertical alignment. Go ahead and fill it. Now
for the size of this text. I'm going to go with a bit
smaller, maybe 26 instead. And I'm also going to change the outline color to
something dark brown, something with this color here. Clicking on Okay. I'm also going to copy this outline color to
the shadow colors. We give this effect here. Then I'm going to give it a spacer search for spacer
added into the horizontal box. For this spacer, I'm going
to write 15 in the X. Then let's add a vertical box, because now we need adding the vertical box into
the horizontal box here. Then let's now add the name. Just copy paste this text again, paste into the vertical
box for this one, this is the name, for
example, we can say, we have some items later on, but let's write something
like Whizz Tower. Just something
random. It doesn't matter right now for this text. This is how many items we have bought so far
from this item. I'm just going to write 999. This is maybe the maximum amount of items you can
buy in the game. Now beneath this item
name, we need the price. I'm going to make
a horizontal box, because we need the on the
coin icon and the price. Adding the horizontal box
into the vertical box inside of here we need an image and then
we need some text. Now for the text, I'm
just going to copy paste this here into
the horizontal box. For the price, we can
write something like 9457 or something
like that randomly. Can even add one more number. I'd like to add a high number because I just want to
make sure my item card is not going to get
bucked whenever we are having like large
numbers for the game. You can even write
one more number if you wish to like this. To make sure that the card
looks fine for this icon, I'm going to go to my icons folder and add this
coin into here. Drag it in now for the image. I'm not going to
draw it as a box, because the box is
just when we want the UI to scale
whenever we drag it. But for the image, I'm
just going to here, horizontally align it and vertically align it
in the middle because You might see here, if you do it like this, you can see it
stretches slightly. This is also noticeable. Whenever you have UI
that stretches more, the image will not
scale properly. Just align it in
the middle here. I'm going to give it
padding to the right, so there is some space between the text and the icon
padding to the right. Give it something like
three. We have some spacing. Now, we also need to
give some spacing to the horizontal box here, because it is on the edges. I'm just going to click
here for the padding. Now for the left, I'll try to
give it something like 25. And to the right, let's give it 25 as well, something like this. Now for the top, let's try
something like 15 by 15. We can give it a bit more. I think if I click back
on the horizontal box, let's give it some 16. I think I'll give it more
at the bottom of 16, 20. That looks fine. Now for
this texture as well, align it vertically
to the middle. This looks great. Okay, let us continue. Now for the shadow, I actually think I'll
write to instead, because the shadow
is way too strong, writing two instead of
three for this one. As the final thing,
let's add the By button. Let's search for button. Actually, we need an
overlay first because we need to add some
text on top of it. If I add the button, let's
see where we add it. Here, We made this
horizontal box. This is where we want to add it. Dragging it into here, and
then searching for button. Go ahead and add it. Now for this button, I'm going to just align it vertically
and horizontally, like this for the style. Let's go to buttons
and drag in this one. Drag it in here. Now for
the tint I'm going to make wide so it doesn't affect
our button for the draws, I'm going to draw it as
a box just like before. Margin 0.5 Now for this button, let's go ahead and give
it a size here in the x. Let's go ahead and
give it some spacing. You can choose how
large your button you want the button to be, but for now let's
just do it like this because let's
add some text first. If I just copy this, copy and paste it into the
overlay for this text, let's align it in the
center of the button. Let's write something like y. This is what it will say. Now I'm going to give
it some padding to the bottom because I think
it's too close to the bottom. The bottom padding is
something like four. Now we have, it
looks really good. What I want you to do here, I want you to change the
color for the coins. We can just use the same
one as we did before. If we go back to
the main menu or the main UI and we can
take this color here, we can copy paste it into the shop item card here
that is a different color. Also for the By button, I want you to change
it into another color, maybe something like green. You can try to choose a
green color you want. I'm just going to go
with this green color. Go ahead and hit okay. Now this is what it looks like. What you need to do
now is just try to stylize it as much as
you can, design it. Here you can increase the Y for the button
if you wish to. You can see this one is not
aligning in the middle. I'm going to click
on this vertical box and align it to the middle. Instead, it looks more correct. Now for this button, I'm
not going to overdo it. Just giving it some
space. So it looks good. I think something
like maybe 150 by 75, and this is what it looks like. Now, you can give it some more spacing if you wish to here, but I think everything
is looking good now. This is our card and we
can always adjust it. It's not like we design it now. And then we can touch it later. We always adjust I
later on because the game changes every
single hour we develop it, maybe in two days. I think this is
not looking good. I can go ahead and
change it if I wish to. I can even change the
color of this and so on. Just design it as best
as you can for now. Now for this text, I just
want to test something. You can see here,
if I write here, it's going to scale
this whole UI. And I don't really
want to do that. The way you avoid this is by basically giving it
a minimum width. If I can just find it down here, minimum desired width, you can go ahead
and increase this. As you can see, it
increases this width here. For this text, I'm going
to align it here to the left and also down
here to the left. In the justification,
it stays to the left for this
minimum desired width, I think I'll write
something like 50. Whenever we change the
number here in the code, you can see if I write zero. I write, for example, 51. It's not going to change
this whole layout. I think this looks a lot better. Maybe I can even decrease
the size of this one, writing 20 instead of this. If I write 999 again, I can decrease the minimum
desired width to 45. Just like this. The same
thing with the item name. So I write something
like tower or make it. This here, you can
see it changes the layout and I don't really
want to do that again. I'm going to give it a
minimum design width here. Just increase it
until you're happy. Now for this text, I'm
going to align it again horizontally to the left and justification to
the left as well. For the minimum design width, I'm going to do
something like 150. Actually, we're going to
give it a much longer name, we can test it out. For example, if we have an
item that has a long name, for example Wizard
Tower Defender or whatever we want
to write here, we can give it a
minimum designed width, 200.235 would be the maximum. We can just remove
this with a tower. Again, for this text here, it's not really going to
affect because it's not going to get this long
that it affects over here. I'm just going to let
this one be for now. But again, you can just give it a minimum design if you wish to. But for now I'll just not do it because I don't think it
will get this long here. The price, everything
is looking good now. All right, so this was it
for the shop item card. And let's go ahead and
change the names because we need to adjust the slater. Now for this text, I'm going
to say item name text. This one down here is
going to be called text Item price by button here. We're also going to change it later because
I want to change the color and make it red
if we can't buy the item. This one I'm going
to say text by. This one is text. Amount of item spots, we don't really need
to do anymore here. If you compile and take
a look at the graph, these are the variables
that we have right now for the text for this UI here, I think everything looks fine. We can always
adjust things later if we wish to change something. For now, let us save everything
now for this by button, I'm going to make sure
that the visibility is set to hit testable, so it doesn't block the button
for this button as well. I'm going to copy paste to the Hoverdm pressed
for the pressed state. I think we have a pressed
state in the buttons. This one I'm going to click
and drag it into here. For the Hoverd state,
we don't have a button. I'm just going to change
the tint of it be slightly different whenever we over
the button and click, okay, go ahead and compile
and save everything. Now if you wish
to test this out, you can always go back to the
meany and it's out of here. You can search for the WB shop
item card that we created. And you can drag this into
the item list that we made, can see what it
looks like if I just control D and duplicate
it a couple of times. This is what it looks like
if I just remove these here. Now what you can do is you
can give it some space. Now in the scroll box, go ahead and give it some
space for the padding. I can write 25, I can
write something like 50. I think maybe 50
is a good number. Now you can see it is
cutting to the side. What you can do is you can
increase the size of this one. Remember, this is the
whole vertical box here. You can go ahead and
increase the size slightly. You can see everything.
What you can do as well is you can click
on the scroll box. I'm just going to click here
on Always Show scroll bar. It's like this. Also
consume mouse wheel. I'm going to change to always so we can scroll always down here. Now let us also design this
handle for the scroll bar. I want you to go back to
your course materials here. And I have given you
this slider handle. Let us import this. If I just get it up here, drag this slider handle
into the images. I'm just going to do
it inside of here. Drag it in here, make sure you add
the pixel settings. Let's right click right actions, apply paper to the settings. Now let's go back to the UI, open up the main UI, and inside of here, clicking on the scroll box. And go down and you can find this
one called bar style. Clicking on it, we had this
normal numb image here. You can change it to
the slider handle. Now you can see it changes. Now again for the box margin, I'm going to write 0.5 instead for the
scroll bar thickness. You can how wide it should be. I think I'm going to give
it something like 18. You can also give
it some padding, some spacing between
those items. And this handle, I'm just going to write zero in all
of them for now. To the left, I'm going to give it something
like ten, so it has some to the top. Let's see if I
think it should stay the same. Actually, zero in the
top, the right is zero. The bottom is zero as well. Let's try it like this. I'm just going to doublcate this
a couple of times. I can also see the shadow down
here, what it looks like. Okay, everything's
looking great. Now let's click on this vertical box And
increase the size of it. So it is not, I think it's looking great so far.
This is what it looks like. You can always reduce the size of this item if you wish to, if the name is too
long. Or you can make, make the name smaller so
you have motor space. But again, we can adjust
it later if we wish to. But for now, let's go back
to the shop item, Cod. What I want to do inside of here is I want to give it
some spacing because you can see there are
no spacing between these elements inside
of the shop item cods. I'm going to click
on the image here. I'm just going to
give it some padding to the top and bottom. To the top, maybe six and
to the bottom six as well. Let's try to see what
that looks like. That looks a lot better. Let's actually give it five
instead of 65 by five. Again, if you wish to, you can always increase
the size of the button. It is not this for the X, For the Y, actually, I'll increase it again, slightly, something
like 80 instead. Just remember to copy this image size to the hoverd
and the press as well. Comp, compile, save everything. Here is what it looks like. It looks really good. I don't think we
will be changing more stuff if I
just maximize it. This is what it
looks like. For me. I might make the
text a bit larger. Actually, let me do that.
It's a bit too small. On my screen, I can make it
like 20 for the text up here, the price as well, and 22 or 24 for the items here compile. I hope we don't need to adjust
the minimum desired width, but we can do it
later if we have to. I think this looks a lot better. Okay, these are
the items we have. Everything is looking good. Also for the buy button, I'm going to change
it to 20 as well. Now we are finished.
Let's save everything, and let us close
everything down. And now we are
ready to continue.
67. 8.03 Item Info Structure & Data Table: Before we can
continue with this, we obviously need some
items to work with. I want you to go into your
cost materials once again, and I want you to go
into the objects folder. Inside of here, I've
given you some icons and you can use them
as items in the game. So go ahead and
let's import them. Let's go to assets
inside of here, I'm going to right click
and make a new folder, let's call it objects. Go ahead and import all
of these into here. Again, I'm going to
click on all of them. Right click and apply paper to the settings once
again. Now we have those. Now in order to use
them intuitive, remember we have to
change them into sprites. We can't just drag in
textures like this, so let's select all of them. Right click and go ahead and say Create Sprite. Now we don't need to extract
because remember extract is only when we have multiple sprites in one image. Right now it's only one
sprite in one image. So we can just go ahead and
click on Create Sprite. Here we have the sprites. I'm going to right
click and make a new folder called Textures, because we basically don't
need all of those anymore. I'm going to click on all of these textures and I'm going to drag them
into this folder. Now we only can see the sprites. Go ahead and save all of it. Next, let's go down
to the blueprints. And let's go ahead and
make our structure. Let's open up the
structures folder. Make a new blueprint structure, item info, ST item info. Go ahead and open it up. Now we can add variables to whatever we want
for this item info. Now for the item info, I obviously need the
name of the item. Just go right name, Go ahead and select string Save. Let's make a new variable. Let's call this one class. And this one is going to
be the item base class. I can see here we haven't
created an item base yet. Let's go ahead and do that in the blueprints Here we don't
have a folder for this. I'm going to write click make
a new folder called Items. Inside of this items
folder. Let's write make a new blueprint
class for this one. Now for the items, I just want them to be normal sprites that I want
to spawn into the world. I'm actually going to
search for sprite and select the paper sprite actor. Go ahead and select this one. I'm going to call
it BP item base. Now you can imagine when you're
creating a game already. Now you have to decide what your item is
going to contain. Because you can see here
if I later on decide that my items are animated
paper flip books. And I have to go ahead and
create a blueprint here, searching for flip book instead, and going to select
this one instead. Create your item base
in a wrong blueprint. This is going to
be a pain for you because you have to
recreate everything once again just when you're
creating a game already from. Now, decide are your
items animated? If they are, you have to
select a paper flipbook, obviously, because flip
books are animated. However, if you don't have
any animations for the items, you know that you can
select a sprite instead. Just make sure that you know all of this before
you create the blueprint. I know that my items here, they are not animated,
they are just images here. Sprites, I create
paper sprite instead. Now we have this item base. Now we don't really need
to do anything with it. So let's go back
to the item info. I just wanted to create
it here in my class. I can search for item base, I can go ahead and select
it as a class reference. The reason why I selected
as a class reference is this is usually what you do
when you want to spawn items. Remember inside
of the blueprint, I open up the player controller, we use this class, this is a class
reference actor class. And we use this to spawn things. I want to spawn
the item later on, so I'm going to add this to it. Then we want to write sprites because I want to
know what sprite it has. I'm going to search for sprites and select Papa Sprites
object reference. The last thing I want to add is how much does this item cost? Coins cost. Go ahead and search for, let's just select an integer. Just an integer. Now we have this finished,
the item info. Let's now go ahead and
add a data table for it. Open up the data table. Right click
Micellaneouselta table. I have to select the structure
item info, the Coke. Call it T item info. Now I'm going through
it a bit faster than before because we already have done this two times before. Now this item info, we need a data table for it
inside of Google Sheets. I want to open up Google
Sheets once again in here. Let me just duplicate this, TT level info, right? Duplicate it. Let's call
this one down here. Let's change the name
to DT item base. Now, inside of here, I'm
going to delete all of this. Delete all of this again. Now for the items, I have to write the name
of every single item. For example, I can
take the first one and you can always copy
paste the method. Again, you have to write the same variable names as what you did inside of the
structure up here to write name. And then
we have to write sprites, and then we have the coins cost, you have to write them exactly
as how we wrote them here, else it's not going to work. Then second thing is you have to write the
information down. Now if I go back to my
table now for the ID, you have to write the item name. If I go back to the objects, I find one of the items. For example, let's say the
first item is this feather. I can call it whatever I want. For example, I want to
call it light father. I can copy paste it into
the name for the class. We haven't created it yet. I go to the items the class. I have to
right click here. Create a child blueprint class. Now I have to create
all of the items. The first one is
called BP Light. You can try to adjust them in whatever sequence
you wish to. For example, the light feather is the worst item in the game. For example, this call or this rainbow could be the
best item in the game. You can just adjust them in whatever sequence
you wish to, but you just have to
create all of them. For example, I can create
them in a random sequence. For now, for example, this crown of evil. Now I can go to the items, right click item base,
create child blueprint. Call it BP brown of evil. Go back to objects, I'm going to copy the Grand Wizard hat. And just do the same thing
for all of the items. And I'll be back with you once I have created all of them. All right, now I'm back. I have created all of the
items here as children. So I basically right click and create child
blueprint glass. Just giving it the name of
the items that I have here, the ones that we
imported over here. Now I have all of them. Let's go ahead and save everything. Now what you can do
is you can go back to the data table to get
this information here. To get the class information, I usually just go to the data table A and add one
row and just select it here, for example. I can select the Lucky or light
feather for example. And then I can hold Shift, right click to copy, and then I can open
up my data table, control V to paste it. This is basically how you do it. Now you can see you have
this light feather pasted. Now again, you have to write
all of the items here. Now, very important,
this is going to be the sequence of your
items, how good they are. Just make sure that you
write the worst items first and then it
gets better and better write them in whatever
sequence you wish to. I'm just going to do
that here as well. Now, I have written
all of them down in whatever sequence you wish to. I just wrote a random sequence
here for all of the items. Now for each of these classes, again, you have to go into here, open up the data table for
the item info, select, for example, the
next one which is, let's select just in sequence. For example, Crown of Evil. Go back to the data table, paste it here for
the Crown of Evil. Now go back again, select
the grand wizard heads. Paste it over in
the wizard heads here on. Just do it
for all of them. Now for the sprite, it's a lot easier because
you can just minimize this. Go to your sprite
here in the objects. For each sprite, right
click reference, then you can go back here, paste it for the Crown of evil. Now for example, the next one, the wizard head right
click reference. Go back to the data table, paste it here, and so on. Do that for the sprite as well. Now for the coins cost, you can do it randomly. Now you can write something like the first item is
costing 15 coins. I'm just going to write equal
clicking on this number, we times 1.5 Then I'm just going to click and drag
this into all this field. So it automatically
adds the number for me. It doesn't really matter
what the price is for now. You can always adjust it later. We're just going to
program for now. I'm just going to fill
all of this right now. All right, now I have filled
all of the information. Go ahead and click on
File and download. Download it as a CSV file. Now go ahead and rename
this to DT base. Let's go back to the data table. Actually, DT base called it
info. That is my mistake. Item info. You also have to correct that inside
of the data table here. Call it it info instead, this. Now we can drag
this into here and should automatically import all of the information for us. So now we have
everything that we need. Now the final step
we need to do, just before we end this, we
can always go to libraries. Now, inside of the
libraries before, let's add a new function called get item info because
we need it later. Let's add here input, call it T name, that is a string. Now for the itam,
let's drag again. Just like before, we
can go into here. And it's basically all of this. You can even copy paste
all of this into here. We're replacing all of the
spaces as you can see here. We want here the DT item info and we can make a
return node, return, it returns the information
for this item here, I can just write item info, compile, make sure
for this item info that you have selected pure. Because we just want to get the information,
save everything. That was it. Now we have everything we need
for the item info. If you just want to test it, you can always go into
the player for example, rightfully can say
get item info. Here you see that you have the item name which
you can plug in and let's actually add the item name before we end this,
just some extra content here, we can
finish it item base. Let's open it up here for
the variables I want to add. We can even call it
name or it name. Let's call it item name. Let's give it a string variable. Compile now, since I
added it to the parent, all the blueprint
children will inherit this variable if I open up the
crown of evil for example, you can see here it
has item name and you have to write this
item name correctly. Now because this is the item name that is going to extract the information
from this data table. If you call this one, for
example, Crown of evil, it's going to find
Crown of evil here. Later on it's going to take
all of this information. It knows what class it has, what sprite, what it
costs, and so on. So you have to write
this correctly and we can use it later. Again, click on all of them. Write the name of them
for Grand Wizard. Add for this one comp item
base, we don't have anything. King's Crown, right? Kings round. I'm just going to do
that for all of them. All right, this is the final
one that is the torch. Let's go ahead and compile
and save everything. Now we have everything
that we need. Go ahead and save everything, and let's move on
to the next lesson.
68. 8.04 Creating the Shop Item Cards: All right, now let's go ahead
and create the shop item. Od, let's now go
to the blueprints. Open up the player control law, because remember here
is where we do the UI. Whatever UI you have to do. I usually do that in
the player control. Instead of here, I am going
to make a new new event, custom event. Let's call
this one create shop items. Because now we need to create them dynamically
through code. Remember for the shop item card, we basically designed one card here as a static card with all of the
information being static. But now we need to change all of this text here to
be dynamic through code. This is why we first
have to create the card and then we
have to display it on top of the menu where we have this scroll box here
in the play control. Let's do this. Create shop
item cards. What we want to do basically, is use this one
called create widget here. Create widgets. And we want
to create the shop item card. This is our main goal. Now we have to create this
for how many items we have. Remember, this
information is available inside of the data
table we created here. We already know how many
items we have from here, we actually know how many of these widgets
we need to create. You can basically do this by
right clicking and saying, get data table row names. Remember this one we used
inside of the function library, but now we need to use this one. Get data table row names. So we're getting all of the names inside of
this data table. Now we have all
of the item names here. We're going to connect it. What we can do now is now, instead of connecting it here, because we need to create a widget for each
of those items, what we can do is we
can drag here and say four each loop. Now we're going to make a loop. Now for each of those items, go ahead and create a widget. Then when you create the widget, I want to add it into an array. If I make a new
variable down here, and I call it it, I can change the type to
this widget that we created. Shop item card. If
I just search for a shop item and this one
here, go ahead and select it. I want to change this
one to an array. You can click here,
or actually up here. And you can select array, Or you can just right click on this icon and it changes
it into an array. Now for this shop item
card, what an array is, if you don't already know you have the single variables
here and you have an array, A single variable is where basically just like
before we used it, we'll store a single piece of information into this variable
so we can use it later. Now, for an array, this is
storing multiple information. We can store all of the
widgets that we create. We can store them into here
to get this information. You can drag and get get, and you get whichever
information index it is in. If I click on this array
here, you can actually see click on the plus.
And I can select an item and I can click
on the plus again, select another item
and you can go on. You can see it saves
multiple information. However, for a single one, you can see you can only save one single piece
of information. But for an array, you
can save multiple. We're just going to
delete all of them. You can see here when you
have all of the widgets, you can also write
for each loop. Now you can do
something with each of those items you have
saved inside of here. We're going to save
this widget here. For each of the items
we create a widget. Each of those widgets, I'm going to drake here and say Add, we're going to add this
into the shop. Item cards like this. The reason why
we needed to change it into the shop It
widget here, type. Because remember if you
hold the mouse over this, this is also a shop
it object reference. Now if you try to make
something else, for example, if I just search for
player base for player and I select this PP player
and I make it into an array, I try to add this into here. It's going to say shop item object reference
is not compatible with the player object
reference because they are not the
same variable type. You cannot do this, they have to be the same
variable type. Before you can add
them inside of here, let me just delete this one. Now we create a
widget for each of those items and we store it
into this array variable. Now I also want
to make sure that this array here does not
have anything inside of it. Before I do this here, before I do anything, let me just copy this, paste it, and say clear. Because I want to
clear this array before I start adding
items into it. Now we're basically
finished creating them. This was it for now. Let's go ahead and compile and let's move on to the next one.
69. 8.05 Displaying the Shop Item Cards: All right, so now we are ready
to display the item cards. Now before I do this, I'm going to delete
all of those. So select these
item cards we added previously to the list and
go ahead and delete compile. Now what we can do inside of the player controller, again, let's rightly make
a new custom event. Let's call it display
shop It cards. Now we are going to display those cards that we
created earlier. Before I do this, again, I have to clear what I have
inside of this scroll box. Remember we have
this VB item list. Let's go back to the
player controller. Take this WB main, because this or this
VB list item list is inside of the WB main. I can drag from here
and say VB item list, let's say clear children. Because I want to
clear all of the items that are inside of it
before I add my card. It doesn't display
random things. Also, if you create
the shop item cards later on for some
reason for your game, you make sure that you remove the old ones before
you add the new ones. Now let's take the shop
item cards that we have. Now we can say for
each loop connected. Now for each of
those item cards, we want to add it to this list. I can copy this, paste
it and say add two. Add child to vertical box, select this one, and now add this inside of here. For each of the shop item
card that I get here, go ahead and add it to the list. That is basically it
if I compile now. Because here if I click Play,
nothing really happens. Because remember we have
never called these events. Let's do it in the players
start or the begin play here. Because usually you just have to think about
in your game, when or where do you
want to call these? You want to call them
from the player, from the Player controller. Now they are displayed
inside of my main Ui, so I can actually just do it
inside of the Begin Play. However, if this was displaying inside of my, for example, a button here that
I had to press a button to open up the shop, then I would not display it
inside of the Begin Play. I would create it.
If I can go up here in the Begin
Play and say Create, shop It cards and call this
event that we created. Now we are calling this event
down here. That is correct. Now, if it was
inside of a button, if I had to press a
button to open it, I would not write this
display in the begin play. I would write it whenever
I click the button. Then you want to display
the shop item cards. But right now we have
this in the main, we actually want to
display it right away. I can actually write it
here whenever I create the shop item cards and everything is added and
everything is complete. Here in the completed, I want to say display shop item cards. So it's doing it correctly. Let's compile and let's
click complain now. And I can see nothing happens. And this is because
I actually forgot to select DT item info here. If I compile complain now, now you can see all of my items. It is not with correct
information because remember we have not yet told it where the title should be, what
the price should be. We have to update this, but you can count here you
have 1-234-567-8910, items. That is correct because
inside of the data table, we have ten items as well. Now it's actually displaying the correct amount of
items in our list. This is what we want. I can see there's a bug with
this scroll bar. I'm actually going
to correct it right away If I just click
on this scroll box, the normal thumb, I'm
just going to paste it. For the hovered, for
the Dr. And hovered, you can even change
the tint slightly. It has some effect
for the drag as well. I'm going to change it slightly. Okay, Click on play now. Everything should be good. Okay, now everything is
displayed correctly. Let us continue
with the next one.
70. 8.06 Giving Each Item Card the Correct Info: Now we have to think
about how do we give each item card the
correct information. So we can change the name of it, we can change the
price, and so on. So let's go inside of the graph. Inside of here, I want
to make a new variable. Let's call this one item info. Let's change the type of
it to item info as well. And we can select the
structure we made. Okay, go ahead and compile. And I can see for the structure now you have all of
this information, but right now it is empty. So how do we get the
correct item information? All of this information here. How do we get this inside
of the shop item card? So we can set the
text for the title, set the text for the price,
and so on correctly. The way we do this is if you go to the shop item card graph, click on this item
info and set it to instance editable
and expose on spawn. You compile and go back to the player controller
now and you click on File,
Refresh all notes. You can see here, you realize that this item info appeared. And again, this is
because we pressed the instance Editable
and expose on spawn. It's going to be exposed
whenever we create the widget. Aha. Now we can take
this and say get info. And actually
we can't do it directly because it is a string. Tally can say get item info. Remember, this is
the function we created in the function library. Now we can drag this into here, and it's going to convert your name string or your name variable into
a string variable. Now we can log this
item info into here. Now for each of those items, basically what it's doing
is it's getting these items for each of the item name
or each of the item name. If I go over to the item info, remember we have a name. It's going to use that
information to get them info here. So basically
it's going to read, for example, with
a light feather, it's going to get this
information for the torch, it's going to get this
information and so on for each of them. It's going to plug it into the respective card
that we created. Then now we have this information actually
stored into here. Now we can continue with the
next lessons where we can actually add or update the
information for this card.
71. 8.07 Displaying the Correct Item Card Info: Now that we have the correct item information inside
of this variable, let's go ahead and
update the information. I'm just going to delete
all of this for now. Let's start with the
event construct. The event construct
will be played whenever you create
the widget here. Remember we made the
create shop item cards. Whenever you create the widgit, this begin play or even construct is going
to play immediately. We're going to update the
information inside of here. Simply what we want
to do is let's start with this item
name, clicking on it. Remember we already
changed the name for it and we set
it to a variable. And we did that
for all of those. Clicking on the first
one, item name, dragging it out here,
dragging and saying set text. This is basically
what we want to do. We want to set the
text correctly. We want to take this
item information now drag it and say break. So we can see all
of the variables. We can simply drag
the items name inside of here and
it will update. Go ahead and connect
it. And you can already see this working if
you click on Play now. And now you see you have the correct name
for all of them. The Protector Night Helmet, King's Crown, and so on. It is updating correctly. This way you know
that the correct information is being displayed. Okay, that was the item name. The second thing
I want to update is the price. Click on this one. Let's drag it and say Set Text. Now for the price, let's
click on this one. I'm going to show
the coins cost. I'm going to connect it here. Break it down. Now
if you click Play, you can see this is also
displayed correctly. Now for the amount of
items we have bought, every time you click and
buy and you buy an item, you have to store
it in a variable, because later on you
need to know how many of those items
you have bought. Now for the amount
of items we bought, I think I'll store this
information inside of the player. If I open up the player
and inside here, let's make a new variable. Let's call this one item pots. Now let's change it
into a string because we need to know which item
are we talking about. Now I'm going to
change it into a map. I need to explain to
you what a map is. If you just drag this out here, we can see a map is a connection
between two variables, instead of it being
one variable. Now we have two variables in one here I compile down here, I click on plus, you can see there is a
field I can write in. This is basically the
string variable over here. I can set a number
here, and this is the integer variable. You can see we have a string
and an integer, and basically you can
have as many as we want. What I want to use this for
is we want to have the item, for example, King's crown. And then how many
of the King's Crown have we bought so far? This is how we are going
to use this variable. But a map, you can basically
change it into anything. For example, you can change
it into an integer here. You can also change
it to a transform. For example, over here, now you can see you
can use it like this, where you have a number which
is basically the integer. Then you have the transform. If you click on here, you
can see the transform. Basically, you can store maybe the amount of transforms that you have in the map or
whatever, something random. But as you can see, a map is a connection between
two variables. But let me just change
it into a string for now and change the second
one into an integer because I basically want to have which item are we talking about and how many of this
item have we actually bought. This is what you're
using a map for. I didn't compile now
for this items bought. Let me now go back to
the shop item card. And I need a reference to
my player because I need to use this variable in
the event construct. Let me just use my
blueprint interface. Get play character
first, get play. Then from here we can drag and say get
play our reference. Remember this is the blueprint
interface we created. Right click, Promote
this to our variable and call it player
pawn for example. And go ahead and connect it. Now that we have the variable, we can now take this
play pawn and we can use it by saying it spots and
we can get our variable. What we want to do,
basically if I go back, this is the item spot,
If I just drag it in, we simply want to set
the text just like before writing set text,
go ahead and connect it. This is basically
what we want to do. We need to know how many of
this item have we bought and which item are
we talking about. We can drag here and
say for example, if you don't know what
you can do with a map, you can always search for map. And now you can see all of the functions you
can use for a map. For example, you can search, find because we want to find the item here when we
find the specific item, for example, King's crown. From here, if I can
spell it, King's Crown, then from here we
know how many of this item we have bought and
we can actually display it. Instead of writing here, what you can do is
we already know which item it is because
we have the item info. So we can drag this
and break here. And then we have the item
name which we can connect a variable. Now
it's going to take this items name that we are in and it's going to plug it in. And from there it's going to
find the item and then it's going to find how many of this items have you
actually bought? But right now we
haven't really stored anything inside of
this items bought. So it's empty right now, but it will have
some information later on when we
actually buy items. I'm just going to
plug it into here and it's going to
display it for me, a compile on play. And now you can see
it is displaying zero because we have no
information inside of it so far.
72. 8.08 Changing the Buy Text Color: What I want to do now is I want to update this by button color, because if we have zero coins, I want to display this or text color as
red instead of green. And it becomes green whenever we have enough coins
to buy this item. Let us go ahead and do this. Let me just close this down. Again, working with UI, I want to do this inside
of the player control. Inside of here, I'm going
to make a new function. Let's call this one. Let's call it updates, store, or update, shop it. And it's a by button or by text color,
something like this. Very explanatory update the
shop item card by text color. Now we need a
reference to all of these shop item cards that
we have inside of here. Remember, we already
have that inside of the shop items array
that we created. I will say for each loop, and we're going to loop
through all of them. For each of them, I
want to take this text. So if I go back and
remember what we called, it is text by and we
made it is variable. Let's go back to the
play controller. Let's drag it and say we
can take this text by. What we simply want to do is if you just drag and say color, if you don't know
what it's called, you can see there is something called set color and opacity. Let's choose this one. Let's drag it in here. Now you can drag
from this and say make slate color because we want to see what
we can do with it. Now we can set a specific
color inside of here. Now I want to set
the color depending on if we actually
have coins or nots. Now we have to work
with the coins. Remember this is inside. Inside of the player, we
have something called amount of coins that
we used earlier. We also have the item
cost which is inside of the shop item card
because we have this item info so we know
the cost of the item. Let's use those inside of
the player controller. You can try to do it yourself if you wish for practice else
let us do it together. Now for this item, I'm
going to say item info. So I'm going to get that variable and I'm
going to break it. So I can see the item cost, going to drag this away here. Now I can see the
item cost here. I'm just going to
hide unconnected pins and only show the item cost. Now I also want the
players amount of coins. I need a variable to the player. I can see I don't have this. If I just go back to the
player controller and I again, actually we can just go
back to the shop item. We can just copy
paste all of this we just created in the
earlier lesson. And I'm just going to rightfully create a variable
for the play upon, and this is a lot faster. Now let's go back. Now we have the play upon,
let's drag it in. Say, amount of coins. Get the amount of coins. Now what we're going to ask is, is the coin cost? Is it larger? Is it greater than the amount
of coins that we have? Then you can drag from here
and say select, select color. Now the difference between
a select and select color. Now if you just drag them
out so we can see them, select color is here,
and select is here. The difference is not
really too large. The difference is if you
do the select color, you can see it
automatically chooses that this is a bullion that
you have to plug into it. For the select, you can
choose whatever you want. You can plug in an enumeration
like we did before, but you can also
plug in this one and it will say true or false. And then you can do
whatever you want with it. Basically, you can
use both of them. I'm just going to use Select
color for now. Select color. Go ahead and plug this in. What it's going to
do is it's going to say is the coin
cost for this item, is it larger than how
many coins you have? If it is, it says pick a. If this bullion
variable is true, it's going to pick
a, it means coins. If the amount of coins that
it cost this item here, if you don't have
enough to buy it, it's actually going to select A. We need a red color
for the A and we need a green color for the beef because this is
where you can buy it. Now for the green color,
I'm just going to copy it from the designer by button
because I already made it. I'm going to copy the
hex linear color. I'm going to go back to
the play controller. Paste it for the, Paste it here, click for this one. I'm just going to
select a red color here first so I can see
what it looks like. Something like this. And I can copy the linear color. Just click cancel because I
don't want to change it here. Back to the, the red
color. And now we have it. It's going to say is the items cost larger than
what you have in coins? If that is true, pick a, picking the red color, if you have enough coins, it's going to pick the green color. It's going to plug it in
here and it's going to set the text color and compile. Now we have to call
this function, because we have
not done this yet, and we want to call it
whenever I click play, I already want all of
this to be updated. The best way to do it is we have created the item cards here.
We create all of them. Before we display them, I want to update the colors. I'm going to add
them here like this. Update compile. If you click on play,
now you can see all of them are red because I
don't have enough coins. However, if I change here in
the player amount of coins, let's say now I have 60 coins and I click
on Compile Play. Now I can see that
for the 60 coins, I actually have
enough coins for all of them, so they will be green. I can see that this text is
not displaying correctly. This is because we have to kill an enemy before it
actually displays. Let's actually fix this. Maybe you want an
initial amount of coins. The reason is we're only running this code whenever we
actually kill the enemy. If I open up the enemy base, we have this amount of coins. If I just copy this,
you can actually copy this whenever
you open up the game. And this comes from the player. If you open up the player and instead of here in
the player base, you can see we made this
update amount of coins. We just need to run this one, update the UI because the
amount of coins is correct. And you can also see this if you take the amount of coins and you print string and you just printed to the screen
and you click on Play. You can see that
it says 60 here. If you saw it. To the
top left, it says 60. It's actually
displayed correctly, or the number is correct, but it's not
displayed correctly. Let's copy this UI. We only need to update the UI, and we drag in the amount of
coins connected like this. Now whenever we click on Play, it's going to update the
amount of coins as well. If I click on Play, it's
going to display correctly. Now everything is correct and we have this displayed correctly
when we kill the enemy. It's also going to add
the correct amount of coins whenever we get
more and more coins. We can now see it's
not displaying this correctly because we need to update it when we
kill the enemy. Let's actually fix that as well. If I close it down, I go over to the enemies, open up the enemy base. And we need to add it here
whenever the enemy dies. And we update the amount
of coins. Let's do it. After we update the
amount of coins, let's use the play controller. And we already have the
play controller down here. Drag it in and say update
shop item card by text color. Go ahead and connect
it connected here. And now it should work. Now if you click on
play and I kill, you can see now if
I get 76 or above, it's going to actually
make this green. If I kill this enemy, we can see now it becomes green. If I just keep killing, you can see now this becomes green because now I
have enough coins, this is working correctly, and now we can move on.
73. 8.09 Checking If Player Has Enough Coins: Now before the player
can press the By button, we also need to check if the
player has enough coins, else they can actually press the By button
and they can buy items without them
having enough coins. Let us try to work
with this one. If I open up the
player controller, once again for the
player controller, let's actually do
something as well here in the update color. What we can do inside of
here, we can drag this. Now let's take the button. I go to the UI and I
open up the shop item and I click on this button. And I'm just going to call it button and make it
a variable compile. Now if I go back to
the play controller, I drag from here and say button. And I take this button, what you can do is you can
drag here and say enable. Now you can see you have
something called Set is enabled. Go ahead and select
it, connected here. Now you can choose whenever a button should be
enabled or not. Meaning that if the player
can press it or not, whenever this one is red, meaning this one is true, This means the player
cannot buy this item, it means they don't
have enough coins. We can actually drag this
and plug it into here. Actually, we can't,
because this is going to be true and this one
is going to be true, which means it's enabled, and we actually
want the opposite. I'm going to again, drag and
say select to inverse it. Go ahead and select
this Select node and plug it down here. Now it might be a
bit confusing now, we don't have enough
coins whenever the item cost is greater than the amount
of coins we have. This means this is going to
be true whenever it's true. I want to set this
to be disabled because we don't want to buy if we don't have enough coins. However, whenever this is false, meaning we have
enough coins here, I want to set it to be enabled. I want to take this and say the button is enabled.
You can go ahead and buy. This is how we reverse it, so go ahead and compile
and click on play. Now we can see the
button is disabled. You can see it is
a bit faded away. Also, let's now check if the player has enough
amount of coins. Let's close it down. Let's
open up the item card. Let's click on it, down
here at the bottom. Let's click on the unclicked. Now whenever we click on this button or we
purchase the item, we want to check if the
player has enough coins. Let's do that inside of
the player because we already made the amount of coins and the
coins calculation like that inside of the player. Let me just make a simple
function, Let's call this one. Does player have enough coins? The simple thing we want
to do inside of here is we want to check if the
player has enough coins. Dragging this amount of coins, let me just also
here for the input, let me add an integer
and let me call it item cost is the amount of coins that the player
has is greater or equal. We have to have equal because it can be equal
to the item cost, which means you
have enough coins. Is it greater or equal
to the item cost? Then we can just
make a return note here, if I just write return the return node and
then plug this into here, it creates a variable for us. This one is basically has enough points when it's
going to check this, we're going to plug
in the item post and clicking on this function. I'm going to set it pure. Because remember,
whenever you have a function that only
gets information, it's not setting anything, then you can set it to pure. Then it becomes like this
green function here, because it's just
getting information. Now what we can do is we
can take this player and say has enough, or we call it it, does player
have enough coins? So it can drag it and say
it does have enough coins. And you can see it's
a green function because we set it to pure. Now we can add in the
cost and then we can get out here and see if we actually
have enough coins or not. Let us do that. Let's take the item info, we can break it. We can take the item cost
and plug it inside of here. Hide the unconnected pins. Now we can drag
from here and make a branch and connect
this branch. Now we actually do this, we're now checking
if the player has enough coins before the
player can purchase the item.
74. 8.10 Purchasing the Item: Now that we have checked that the player has enough coins, let's go over and just
purchase the item now. Now for purchasing the items, I think I want to do it
inside of the player. Whenever you purchase here
and you have enough coins, you go ahead and
purchase the items. Let's make a new
event in the player. Let's make a new
custom event called purchase item like this. Now for this purchase item, we obviously need
the item first. If you don't want to do it
right now, let's just go back and inside of here,
let's take the player, we already have the
player variable. Let's strike from here and say purchase item and call
this event we just made. If it is true that we
have enough coins, let's go ahead and
purchase the item. Obviously, we need to
know which item we are talking about because we
need some information here. I'm just going to create an
input and let's call it, or let's call it the
item info structure. We have that item, I'm
just going to call it item compile Now we can go
back to the shop item card. The item is obviously
this item we are in right now and we
already have the structure. I'm just going to take it
and plug it into here. This item information is going to go through
to the player. From here we can now
do things with it. The thing we want to do
is obviously we need to subtract the amount of coins the player has. Let
us try to do that. Now you can do it
yourself for practice, because I think you
can do it yourself. Now if you don't
remember how to do it, let's do it together. So you can take the amount
of coins that you have right now and then say
minus to subtract. Then we have the cost
of the item here if you drag from here and
say break item info. Now we have the item cost. We can say the amount
of points that you have minus the
cost for this. We can take this amount of
coins and set it again to this new price or this new
amount of coins that we have. We're just going to click here. Hide unconnected pins. Just go ahead and make it
more structured like this. You can also print a string. Actually let's not
print a string. We can just update
the UI instantly. Let us just do it
like this up here. I'm just going to copy this. Update coins, amount I. I am going to log it in like
this. Let us compile. Let's see what happens if I
click on play. I have 60. If I buy something for 23, I have 37 left. I buy again for 34, I have three left. And if I click here, you can see I
cannot keep buying. Because remember, we already checked here if the player has
enough coins or not. We are not able to purchase the item if we don't
have enough coins. That is working really good. Now, the problem right
now is when I buy, you can see the buttons
don't get read. It looks like I still have enough coins for this
one, which I don't. Let's also update the buttons. If I go to the
player controller. Let's open up the
player controller. And remember inside of here
we made this function called update shop item by text color. Let's call this one. Let's go back to the player. Let's take controller Pasted in here. Let's call the updates job
item card by text color. Let us plug it in here. It should update it
every time we purchase. Now if I click on Play
and I purchase something, you can see they become red. And I can't really
purchase them. And they are disabled.
If I purchase this one, they all become red
because I don't have enough points now that logic
is working really good.
75. 8.11 Updating the Amount Of Items Bought: Now it is time to update how
many items we have bought. Because remember, we made
this one called Items Bought. And we need to store how many items you have
bought during the game. Also here when we click on
play and buy something, it doesn't really show
you that you have bought something because it's
still zero over here. We need to update this
information to do. I don't remember where we
used this one. If you want to just try to remember
where you used something, you can always write,
click and find references. And we can see it says
no results found. And this is because it's only searching inside
of this blueprint. But if you click on
this small icon, it will search across
all of the blueprints. Double click on this one. You can see we have used it here inside of the shop item card to update the text here of how
many items we have bought. We have used it over here to update how many items
we have bought. Let's just go back to
the player and here whenever we purchase
and update the button. Before I update the button, I'm actually going to edit the map. Take this map here, drag it out and say Add. Now we want to add one
more item to the map, because now we have
bought an item. What you can do is you
can take this again, you paste it, because you can't really add
information right now. What you need to do is we
find and have this function. What you're trying to
do is you're trying to find the item that is
already inside of it. If you just write a number here, if you write, for example, one, it's going to overwrite the information you already
have inside of here. Let's say it was
the golden crown that was inside of here.
If you just write one, it will be one
forever because every time the player purchases
it will be one. It will override this item here. We need to keep updating it
with a higher information. Now we need to find the
item first inside of the array or inside of
the map to find the item. Remember, we already
have the name. If I just take it up
here now I can use this item name and we can find this item
inside of this map. Once we find the item, we now know how many of
this item we have so far. This amount here, what I want to do is I want to take this number plus it with one plus one. Now we are adding one to the
items we already bought. Then you can plug
it inside of here. Also, remember you need to
plug in the name here as well. Just let's drag it from here. Plug it in, and again, just make some mirrored notes. It looks nice. And I'm just
going to plug this one over here like this and
this one down here. Okay? What we're
basically doing is we're finding the item inside
of this map first, and then we know how many we already have bought
and we're adding one on top of it and then we're just putting it
back into the map. We don't lose that information. You click on play
and you press on by on something and see
it's still saying zero. This is because we
haven't updated the UI. The UI is inside of
the shop item, Cod, and it's this text here that you need to
update once again, because this part
here is only updated whenever we create the Cod
and it's not updated anymore. We can make a custom event down here and I'm going to
make a custom event, update items bought UI. What we can do here,
basically we want to set the text, this text here. I'm just going to control C, control V down here. Let's plug it in.
Basically, just want to do the same thing
that we did over here. Let's just control x to clip it and control V
to paste it down here. I'm just going to
connect it here. Instead of having
this code up here, we can basically just delete
this one and add this one. Update items, I instead just add it up here,
update items I. Basically, the reason why we write it up
here in the begin, play or event
construct is because we're making sure that we have
this correct information. Whenever we open the game
and we take a look at this, this is the reason why
we add it up there. Because if for example, let's say you have a
load and save system in the future and
you close the game whenever you open it up, this will run again
and it will update your information with
whatever you have saved. That is very important to have. Okay, so we have this
update items, but UI, we need to run it from the
player if you go back and we need to run it after we
add the item to this map. Now what we need is we
need a reference to this shop item card widgets because now we need
to use this one. Update items, put UI. But as you can see, we don't really have a reference to it. We have this one called
shop item cards and we can basically use
it to find an item. But again, we don't really have this information
out of here. We need a way to
reference this card. Now you can do this in two ways. You can either here in
the Player controller, you can basically just make
a custom events called, for example, sets, interacted shop item card or whatever you want to call it. Basically just add the
item shop item, Cod. Again, basically you can
just call it from here, use the player controller, We need to have a
reference to it up here. Basically you can set it
through the player controller. And from the player, we can use this variable here to
actually update this card instead of doing it this way. For now, I want to
try the other method. The other method basically, is you can just go back to the Or to the player here
for the purchase item. Let's just add a new variable. Let's call it shop it Cod. We can always change this
way if we in the future find out that we could make it
into something better. But for now, let's
search for item Cod. Go ahead and select it, compile back in the shop item. Let's see over here
in the purchase item. Whenever we buy something, I want to set the
reference to self and say self. Basically
we're defining this shop item cord to be this
card we are in right now. This is what self means. Now this information, we have it whenever we purchase an item, whenever we add the item to the items but map
we can now call the update items but UI drag from here and
say update items. But I go ahead and connect, it's like this again. You can double click to
make a rear route node. Whenever that is done, this should now update the UI. And then go ahead and plug in this update shop item Cod by
text color back in again, save everything. And now
let's play and see what happens if I buy
one of the torches. See I have one. If I buy
one again, I have two. Now it is calculating correctly. Now if I give myself
a lot more money, so if I go back to the player and inside of here
the amount of coins, I just put it to something like 1,000 or 10,000
100,000 or whatever. Here it is. Now you can
see if I just keep buying, just want to see if it works
and it is working correctly. You can keep buying. And you can see the UI
is staying the same. The UI is not changing the
text position and so on. Everything is working
nicely and also the money calculating correctly. So now that is fully working.
76. 8.12 Creating Item Spawn Points: Let's now go ahead and add
the items spawn points. What I want to do is
whenever I buy something, I want to spawn these
items into the world. And this is basically the
same idea as cookie liquor. It's the same idea where you buy something and it spawns
into here on the screen, I think it's a bit
more interesting. So let's go ahead and do, or make some paint points
inside of here. Remember we already made a point point for the
enemy which is over here. Let's just use the same method. So we have the enemy and we
have the spawn point base. This is the parent class, so I'm just going
to right click and create a child Looprint class. We can call this one
BP it, Spawn Point. Now this is the point point. Which item are we
going to spawn? We can basically place it into the world and we
can just set Y20, it is in the front and I'm
just going to set it to one so it's in front of the
tiles. We can set it something here, save everything. And I'm just going to hold
Alt and drag to copy it. Now you can see we
have two spawn points, but how can we choose if it is the holding crown that should spawn here or if it is another items that
should spawn here. We can do that by exposing
a variable to them. What we can do is
we can go back to the spawn point base
inside of here. What we can do is we can
create a new variable. We can call it it name or we can also just call it
actually spawn point name. I think that is a bit more descriptive to this point point. We can change it into a string, save. Remember if you click on Instance Editable
and Expose on Spawn. We already used this when we added the information
into the item cards. When you do this
and you compile, you can see here
inside of the world, you have this pin over here, the spawn point name. This is the same variable as this one because
you made it to instance editable and expose on spawn. It appears up here. What we can do with this one is we can click
on the first one, for example, we can call it, let's see which items we have. We have the P. I'm just going
to use the light feather. The first one should
be the light. Write the name precisely. Remember this name needs to be the same as the one
in the data table. Whatever name you have here, it needs to be the
same one as out here. The second one is the torch. Now we have both spawn points. Now we know which items
should spawn where. Now we are just
missing the logic, and we will be doing that in
the next couple of lessons. But now we at least have the
spawn points to work with. Let's jump over to
the next lesson.
77. 8.13 Spawning the Bought Item: All right, now let's go
ahead and spawn the item. Let's try to work
backwards from this one. Now, whenever I spawn items, I'd like to work backwards
because it makes more sense to when or where we need to add our events and functions
for the spawning. Remember, I use the
Player Controller to spawn things into the world. So if I go inside of here, we already made this
spawn actor here. Spawn actor. Let's just stay consistent and
do it inside of here. I'm just going to directly
make a new custom event. Let's call this one spawn item. Okay, for this one, again, we need to use a
spawn actor from class and selected for the
item we want to spawn. It really depends on which it. Now, this is getting an error. I need to disable this. Depending on the item we buy, this is the item
we want to spawn. We can't really set
a static value, we just need to
drag it into here. Drag this back in, I'm going
to call this one item. As for the location of the item, I don't really need
to use a transform. So what I'm going to do
is I'm going to say make. Whenever you say make transform, this is basically because I
want to see the location, rotation, and scale values. This is why we use make. You can drag now this
location into the event. So it creates a pin note for it. And I'm just going to
call it spawn location because I'm not
really interested in the rotation and the scale, it's going to stay the same. I'm only interested in the location that I want
to spawn the item in. Now this spawn item, where does it make
the most sense to play this event or
to call this event? The place would be whenever
we purchase an item, we calculate the price
over in the player. Whenever we purchase the item, we add it to the
variable or to the map here and we update the buttons. After that I can spawn
it into the world. Basically spawning it is
in the Player controller, so I need the Player
Controller again. Or you can drag from
here if you wish to. And you can say spawn item,
provide and selective. Now you have to specify which
item are you talking about. Now we already have
this class from here. I'm just going to break
this one once again. Take the class,
plug it into here, and hide unconnected pins. I'm just going to
take it closer here, double click to make a node. Now for the spawn location, we need to be more
specific here. Because we need to have saw or the location
of this actor here, the items spawn point. You can always go
back to the game mode and take a look at
how we did it before. If we go back to the begin
play, we use this one. Get actor of class. And remember this function, get actor of class, gets anything that is already spawned into the world
when you click on play. Because if you say
get actor of class and you have this inside
of the level right now, is going to give you an era. Remember, this
function only gets the actor which is already
spawned into the world. We already have spawned those. So we can actually use
it, get actor of class. Let's just do it inside of here because
actually this is not the method we need to
use get actor of class. We can take this
one basically we say spawn point
and we can select the item spawn point we can drag from here and say
get actor location. We're now getting the
actor's location, which is this location here. And we can plug it in Now
let's just see what happens. We can just click on play and I basically try
to buy something. Nothing is spawning and it's
actually the correct one. I'm just wondering why
it's not spawning. Let's see if we actually
added the items. This might be the
problem right now. If we open it up,
go to the viewport, I can see we haven't any items. I'm actually going
to do that now. For all of the items
we created earlier. For example the Crown of Evil, we need to select
the source sprite. Go ahead and select it here, so it appears here, compile. Go to the next
one, Grand wizard, hats, click on the
render components selected here, compile next. This is the item base, so we don't really need to
add anything here. Going to the King's Crown. And we can actually
do it from here instead of clicking up here. The next one is
the King's Crown. All right, This
was the last one. Now I have added all of them. And I'm just going to go
ahead and click on Compile for all of them to make sure everything is
working as expected. Okay, close everything,
Save everything. And let's click on Play
again by the Light Feather. Now you can see the light
feather is spawning. And if I buy the torch, the
torch is spawning as well. Both of them are responding. They're spawning
in the same place. But we know that this
pain point is working. Now in the next three lessons, I'm going to show
you three methods on how we can spawn
those efficiently. What I want to do, basically, is from this point point, we want to spawn
all of the items, but for now, everything is fine. Now if you want to reduce the size of the item
that is spawning, now here in the item base you can basically do
is in this scale, for this item, you can
click on the lock. It changes all three
values at once. And if I write 0.5 I click
on play and I buy something. You can see that the
item is smaller now. Now for the Em, I think I'm
going to go with the scale of 0.25 because the
icons are very large. If I click on play now
and I spawn something, you can see this is the size I like, the size of this one. You can always have a Bitloga, but we're going to
have a lot of items. I think this is a
good size for it. Okay, let's save everything, and let's move on
to the next one.
78. 8.14 Spawning Logic: How over the next three
lessons I'm going to show you how we can do
this spawning methods. Now the first one
is going to be easy and then we are going to
something intermediate, and then something advanced. I hope you'll stick with
me for all of them. Let's start with this one, which is the easy method. Now for the spawning, I'm going to do that inside of the game mode because
this is basically where we are calling
the spawn points, where we define them. Let me open up the game mode. We already defined the
enemy s paint point. Now it's time for this one now. Instead of doing it out here, let's actually create
a function for it. Because it's going to be a bit larger than just
doing this here. Let me just make a
function out of here. Let me call it set
items, points. I usually have an in front
of them for function, and I'm just going to
do it here to stay consistent for this one as well. Compile and save
now for this one. What you can do now before we start, just so we don't forget, I want to call the
Spawtpoints here, drag the function into here,
go ahead and connect it. And so now it works, okay? So now we have to do something
inside of this function. What I want to do first is I want to get all of
the St. points. So to do that, let's say
get all actors of class. Remember this function,
you can only use it for things that are already
spawn in, out of here. And we already have St.
points inside of here. Now realistically we will have
a St. point for each item. So we will have a lot more. Whoops, we will have a lot more Spain points
like this here. But for now, let's just
delete all of those. And I'm just going
to stick with two. Whenever this method works, I'm just going to
copy all of this. And it will be like
5 seconds of work for now. Let's just have these
two and work with those. Let's say get all
actors of class, and let's search for item
spa point, this one. And it should get
both of these ones. If you want to see
what it actually gets, you can always print string you can drag from here and
say length, so you can see. How many spawn
points did we get? It should say two. If you click on play, it
says two up here. If you can see it, we know now that it gets both
of those S points. Awesome. What we can do now is we can drag from
here and say four each. Now we can do something with
each of those spa points. What we want to do is we
want to basically define the location. Because we need the location
inside of the player. Every time we spawn an item, we need the location of the spawn point for the
next item we want to spawn. What I want to do is
I don't want to spawn all of the items here
on top of each other. What I want to do here
is I want to spawn items in a line. I want to
spawn the first item here. I want to spawn the
second item here. Third item here, fourth, fifth, six, and so on. Now, you can do it like this, it's not a problem. But imagine if you have 200
items for the first item, you have 200 for the second. Your whole level is going
to be spammed with actors. I don't think it's
a good method, so I'm just going to
delete all of those. But basically this is
what we're trying to do. We're trying to spawn
all of the items in a line here. Let
us try to do that. Let's go back to
the game mode now, what we can do inside of here, it really depends on which
item we need to spawn. Remember, for each
spawn point we made the Spain point name
variable which we exposed and we wrote
light feather. Let's drag from this one and
search for spawn point name. Go ahead and get that variable. Now drag from here and
say switch on string. Now this is just
like before where we use the switch on enumeration, switch on string, you
can do that as well. Click on the plus to add pins. The first one, the first
item we have is the torch, or actually the light feather. Then we have the torch, we have these two compile. Now what we can do here, if
it is the light feather, we want to use this point point. It is a torch, We want
to use this point point. Let's start with
a light feather. What we want to do is first let's actually
create an array. Because we can't really do this without an array to store
the locations we find. Let me change this
into a vector. Let me call this one light
father spawn points. Let's take that one out here. Now we need to change it
into an array because it will be multiple
locations we need to store, which is this row here of
items we need to spawn. Instead of a vector,
you can right click it. You change it into
a vector, or again, you can always click on it and change it up here
if you wish to. Now we have this array. And what we need to use with
it is the add function. So we need to add a location and we need to add
it inside of here. Okay, Now, it depends on what locations we need
to add. How do we do this? How do I get different locations simply from one spaw point? Because I'm not going to
add more spawn points. This is the only spawn point I'm going to add for
the light feather, but I want a lot of items
here that I need to spawn. What we can do is let
me just do it and you can actually
see how easy it is. Firstly, we obviously need the location of
this Spain point. First, I'm going to drag
this and say it at location. Now I have the location
of this spawn point. What we can do
with this one is I can make a four loop loop. We can select this
four loop here. Now it depends on how many items do you want to spawn first. Let's just start
with five items. We are going to write four here. The reason is, the
first index in a loop is 00, comes as 101234. That is, five items, 0-4 What we need to do is we need to get
this Acts location. Now you have to think you are going to spawn the
items this way. You have to pay attention
to what axis you are in. This is the x axis, the
red arrow is the X axis. If you click on it and
you drag the item, you can basically see down
here in the location, in the details panel
that you are going in the plus direction
of the x axis. This is basically what
we're trying to do. I don't want to affect
the Z and I don't want to affect the Y either. I just want to affect the X. This is why we can
take this and we can say break vector because we only want to affect the
x axis. Also for this one. Since I can't log
this into here, I will drag from this
and say make vector. Now I also can see the x, y, and z and we can basically drag in this
information into here. Now for the Y, for the z, I don't want to change anything. I don't want to affect them, I just want to affect the X. Now what I can do is I can say the X loss maybe like ten units. So basically what we're
doing is we're taking this location and then
we're adding ten units. The next item will
be here instead. Let's go back. We're saying ten, and then we're
plugging it back in. We're taking this
location, it already is. In this one point, we're adding ten to
the x and then we're plugging it back in and
this is our new location. Obviously, we can't just plug ten in and just keeping
ten in out of here, because this is going
to be the same, is basically going to add items to here
instead, all of them. What we need to do, we need
to use this index again. The index is going to be
zero first, then 123. What we can do is
we can basically multiply this number here. Instead of just writing ten, we can drag it,
multiply, select it. What we can say here is we can say ten multiplied
by index here. And that should work just fine. What we're saying is ten
multiplied by zero first, which will be just
this spawn point. We're saying ten
multiplied by one, we're saying x plus ten. Then the next item
would be here. Now again, it's going to
go to the index of two. It's going to say ten times two. That's 20. It's going
to say x plus 20. The next item will
be here, and so on. It will just loop and add
locations like this here. We're going to
delete all of this. And now we can connect it. We can actually try it out and see if that works.
If I just save here. And we can try to spawn it in the player,
in the spawn item. We obviously need to delete
this now that we created earlier and we need to add the locations
from the game mode. I don't really have
the game mode here, let's just create a
quick reference to it. If I say get game mode, remember this is
in the Begin Play. Let's get the game mode. Get
game mode reference because remember we already made the
blueprint insterface for it. We can right click,
promote this to a variable called game mode like this. I didn't connect it. Let me just rearrange this now. We can take the game mode. I'm just going to
move this closer. We can take the
flight spawn points, we can get them here. We can also say get because we need to get the Spain
point. Get a copy. Now, it really depends on which spawn point
you need to get, because it depends on the
items you have bought. Actually, what I
need to do here is I need to just say find. Because it's going to find
the item you have bought. It corresponds to the
item, the spin point here. Now find the item
you have bought. And it really depends on how
many items you have bought. Now since the bought item
will always be one above, because we're plusing or
we're adding one here. We need to take this
and say minus one, because remember we
start at index zero. We don't start at index one. When you have bought one item, we need to minus this by one
and then plugging it in, because the first item
will spawn at index zero, we always need to say minus one compile and
then just plug this in. Click on Play, try to
just buy light feathers. Now you can see it is working. We are actually
spawning in a line and it's not going
to spawn anymore. Because you can see
it spawns up here. That is because we
only defined it to be 0-4 Now you can always write 99 and this will
spawn 100 items. Now it will go to the right
100 times before it stops. Now you can see this is
working really well. Now if you want to do it
for all of the other items, you obviously have
to take all of this. You have to copy paste. And you have to do this
here like this before. Whenever the first
is completed here, you also have to do
it for the torch. Actually, we also need
to copy this one. And we need to do this as well. You can see here, this is
a lot of copy pastework. You can do this a lot better. Because remember we have, let's say we have 50
items in the game. You have to copy this 50
times for all of the items. You can see this is not really
good programming practice. I would never do
this in my game. I'm just going to delete
this. This was the first. This is the easiest
method we can do it in. I have a method which
is a bit hotter. Let us just continue
in the next lesson.
79. 8.15 Spawning Logic - Intermediate: All right, so now we are back. And what I want to do now, before we change
this whole method, I want to improve it a bit. Because we are going to
use this improved method. We're not going to delete all of the things
we're doing right now. Let's just continue on
what we have currently. Now, I need to
change this later, but for now let's just keep it and let's
keep all of this. But what I want to
do right now is if I click on Play and buy items. I also, whenever it reaches
a certain amount of point, I want to make it
by in the next row. It doesn't buy in only one row, but it also buys
in the second row. Now I can see this one
bugs out because we only have set it to
four in the index. But as you can see, if I just keep buying in this row,
it can get too long. What I want to do also is
it automatically goes to the next row and it buys
or spawns items there. Let us add some
logic to it first, let's just write
five or four here. Just like before, I need to know when is this loop finished. Let's right click on this one. We can promote it to
a local variable. The difference between a
variable and a local variable is a local variable is inside of this function
you are in right now. We are inside of this set
item spawn points function. If I create a local Spain point and I go back to
the event graph, I will not be able to
see the variable here because it only exists
inside of this function. We basically needed to do
some logic inside of here, but we really don't
need it to be out here. We're only using this to when the loop is
finished or not, we can right click here,
promoted to a local variable. I usually call them
local to begin with, let's call this one
loop, last index. Because this is the
last index of the loop, we also need to make
another local variable. I will change it to an integer. Again, it's not an
errageous normal one. The second one, I want to just call it local
amount of rows. I need to know how many rows do I need the items to be in. Do I need it in one row or do I need it in two rows,
three rows, and so on. For now, let us just
add three rows. If I compile, click
on the variable and over here in the default
value, just right three. Now we want three rows. What I want to do here is I
want to take the local loop. Last index I want to say, is this equal to the
index right now here? Because this index here
is counting upwards. And you can see that
if you print a string, you can always print a string
if there's something you don't understand or there's
something you want. Clarity four, you can just drag it into
here and click on play. Now you can see it
prints the number. And if I just make
it longer here so we can see what's going
on and make it read. Click on Play. You can see
it in the number 01234. It counts upwards
if this is equal to this local loop lost
index, which is this one. If we just compile,
you can see it is set to four right now if
this is equal to this, we know this is the last loop
that it has gone through. Just connect this one again. If that is true, we want to take this amount of rows
we want to compare it to. How many times did
this loop run? Let's say you need
three rows here. You have to run the
loop three times, because the first time it
loops and loops to this row, then it needs to loop
here and loops here. If we have written the
amount of rose to be three, it needs to loop three times. I'm going to make a
new variable again. Let us call this one
local loop counter. Let's take this
local loop counter and let's say loss plus, because we need to
increment it by one whenever the
loop is finished. This loop here now is finished. If that is true, we need to add one to the
local loop counter. We need to ask, is this
local loop counter, is it less than the
amount of rose? If it is less, right now it is less
because the amount of rose is three and this
one is only one. Go back and loop again. If this loop counter
is now three, it will not loop again
because this is also three. And we will stop the code. Just go out and
connect this here. Now if it is less than
the amount of rows, we need to run the loop again. Let's take this true here and let us just run it
back to the loop. Let's take this
execution pin here. I'm going to double click
to make a rear route note. So I can actually
see it like this. Now we are going back and
looping this once again. Now if you click on
play and you buy. You can see nothing
is happening. Why is nothing happening here? But you can actually see
something is happening. Because if I buy five like here, and I remember set the
last index to four, which means I can spawn five
items by the sixth one. It's not going to
bug out five by ten. It's not bugging out if F by 15, but if I buy 16, you
can see it bugs out. What's happening right
now is you're spawning the 15 items on
top of each other, you're not taking the next row. The reason is, remember
you need to affect the z value because the row is basically
the Z value here, we haven't affected the Z value. You need to do something
with this z value. What we need to do
is we need to see which direction do
we want to go in. Now if I click and
drag this down, just pay attention
to the z value here in the details panel. If I push this down, it goes in the minus
of the z here. What I can do is I can take
the z value. I can say minus. We just need to do
it just like before. Actually, if I can take this here and say multiplied
just like before, I'm going to move this, I'm
actually going to delete it, because we don't
really need this one. We can always copy paste this
one up here if we need to. Again, we need to
multiply it just like before. Let us say for ten. And it's not really
the index because we don't really want to multiply
it in the same loop. Because the first
loop, the z value is the same all the way. In the second loop, the z
value is the same all the way. It's not going to change
every single index here. Instead of doing this, we need to make another local variable. Let's call this one
local z axis multiplier. Now for the default value, it's going to stay
zero because we don't want to multiply
it with anything. The first loop, so the first
loop, this is all correct. Let's just connect it here. Everything is connected. Now,
it says something is wrong. The current value of a valid, a valid number. I don't know why
it's saying this. If you click on File
and refresh all notes, I don't know why it's
bugging like this. Just drag and say
multiply again. I'm going to drag it down
here instead saying ten God, And connect it once again and compile. And
now it's working. I don't know, it was
just a random bug. Now we have this connected. Basically what we need to
do is we need to increase this local z axis multiplier. Because for the first loop we want the z to be the
same all the way. For the second
loop we want the z to be the same all
the way, and so on. Every loop the z changes. We can do it over here. Let's
take the local z multiplier when we know that we are
going to loop again. When this is true, let's
just increase this by one plus plus connected and go back in the
loop like this. Now it should work if I compile
and if I click on play. And if I buy the light
feather five times six time, it should be down here,
which is correct. And you can see everything
is working correctly. Now you can see how great
it is that we spawn all of these items from a
single Spain point. Now you don't have to spam your map with a lot
of Spain points. This is very optimized
because this is only running whenever
you start your game. Because it's going to store all of these Spain points into array which you can
use later on to actually spawn the items.
Let us save everything. That was it for now
and we are going to go in the next one and make
it a bit more advanced. I hope you are still with me, but what we are simply
going to do is we are going to get rid
of this part here. And I'll show you how we can make this a bit more advanced. Let us click on File, Save All, and let's move
on to the next one.
80. 8.16 Spawning Logic - Advanced: Right now, we are going to improve the code we
have written here. So this is the last
part what we can do. Instead of doing all of this, let me just delete this part
for now and also this one. For this items
point that we get, let's just right click
here and promote this to a local variable.
Let's call this one local item, spawn points. Now we have those
spawn points also. Before we do all of
this, let's make sure that it is not zero. We're just making sure
that we actually have some spawn points and that the map actually
contains spawn points. So drag from here
and we say length, we make sure that this length is greater than zero and then
we can make a branch. Wow, we're making sure we actually have some spawn points. Before we do all of this logic, else it will not make any sense. Let's strike this away from this for now and go ahead
and connect it Now, when you take a
look at this one, you have to think of
how can you make this smaller than before?
Instead of taking this code copy and then
pasting down here, and then connecting
and then continuing. How can you shorten this method here so
you don't have to copy paste what is different from this code to this code
that you need to change. Now the first thing
that comes to my mind is I take a
look at this array because first you have to add the locations for the large
feather spawn points. Then let's make a new one. Just click on this one
control D to duplicate. The second one is the
torch spawn points, I believe the second
one is the torch. Yes, it is. The second
one is the torch. We actually need
the torch down here where you need to add the spawn points and not the
light feather. This is the only difference. Now, in order to
shorten this again, remember to use the select node, A very important and
powerful node you can drag from this one
and then say select. Now you can select the feather or you can select the torch, depending on what
you plug into here. Now how do we know which
to select where that is? Again, where you can
use enumeration. If I go back in the
items I can write, click Make a new
blueprint enumeration. And let's call this one items. Let's open this one up.
Let's just add some items. Now I'm just going
to try something in. The first item is light feather. The second one is Torch. We can always try to
see if that works. If it doesn't work,
doesn't really matter, then we have learned
something from it. If I go back now, I have this enumeration. I will actually add
this enumeration to this Spain point because we, again, just like the
name, we need to set the enumeration correctly. Let's open up the
items pain point, because previously we
added this item variable, or this spain point name variable to this point
point base. Which here. But it doesn't
really make sense to add an items enumeration to the point point base because the enemy
doesn't really need it. Why would you add it inside
of the point point base? Because remember the point point is the child of this one. I don't want to add
unnecessary variables where you don't really need them in all of the other actors. We only need them
inside of here. Let's add it inside of here. Instead, let's add a
variable, call it item. Let me just search for items. Items. This is what we
called it. Go and select it. Compile. Let us save
everything again. Expose, Instance, Editable. Expose on spawn, compile. Now if I click on it, I can change the item
to light feather. And the next one I can
change it to Torch. Now we have this information. Now if I go back
to my blueprints, open up my game mode. What we can do inside of here
to get this information. Remember, we already
have this info here. So I can take my local item, spawn points, I can say gets. And I'm just going to
get the first one, then I'm going to say item and then I'm going
to find my enumeration. Now go ahead and
plug this into here. Now you can plug those back in. Now can see depending
on what this value is, it's going to select
those arrays. If it is the light
feather which you have selected out here in
the expose a spawn, it's going to select the light
feather array and so on. I can see it's going
to work just fine. Also down here for the
get actor location, it needs an actor
go ahead and copy paste this and
paste it over here. So that will work just fine as well after it have added the spawn points
for the first here, for the first it needs to. The second one when when it reaches the second
one over here. Now remember we asked, is the local loop counter larger than the amount of
rows you wish to have? Smaller, larger if it's smaller. If that is true, we just
go ahead and loop again. However, if it is not smaller, it means we need to stop
the loop because we have reached the maximum
amount of rows for this one, we need to go to the next one. What we can do is we can take
this and we can say index. Because we know that
we need to remove index zero because
we're basically using the first index to we basically spawn the
items in out of here, Remove the first index
which is index zero. Before we loop again to
the next spawn point, we need to make sure
that this is not empty. Because what happens if you
reach the last spawn point? We don't want to keep looping. We have to drag here
and say is not empty. Because we want to loop
whenever this is not empty, let's make a branch, go
ahead and connect it. If it is not empty, we want to loop again. Now remember, we need
to reset the Z value, because again we
are in a new row. We need to reset all of the
settings for the Z value. I'm going to set it zero. And then for the local
loop counter as well, because now we're starting
a new loop counter, I'm going to set it 20 as well. Let me see if there's something
else we need to change. Now for the local loop
index, we actually, this is staying the
same because we have the same amount
of items per row. We don't really need
to change anything. Let's compile and
save everything. Now for this one, we're basically going to plug it back into the loop like this. Again, double click
on it so we can see what we are doing now. Let us see if it is
actually working. Now, before we click play
and we try to do this, you can see it is spawning
on top of each other. I don't think it's
a mistake here, because remember
in the player you also choose how you
actually call this. We only had the light feather
spawn point we got from. You. Actually also need to
make this a bit more dynamic. Now again, remember you have
to get the location here, the array, depending on what
the item is to do this act. Because here you have a
string and what you're using inside of the game
mode is an enumeration. You can't really
use those together. You also can't plug a
string into an enumeration. If we got it out here, we have
to convert it in some way. Let's make a new
function up here. Let's call this one,
get it spawn points. This is only getting
information. Remember to set it to pure, so it becomes like
a green function. We're only getting
information here. Now for this one,
what we could do, for example, we could
search for items. We could use this
enumeration like before, and we can say switch
on enumeration. And we can basically assign the spawn points depending on
what we are talking about, which item we have selected. The problem with this is if
we need to use this one, Get it son points. If I compile and go back to the player and I take
the game mode and say we call it gets spa points. Get spa points. I tried to use this one. If I try to plug this into here, you can see it
says string is not compatible with
items enumeration. Now we could add the items enumeration
inside of the structure. I don't really want to do that, but you can do it if you want. That is also a method
that can work. But what I want
to do, instead of making this into an enumeration, let's actually make
it into a string. Select a string instead, and let's call it item name. Let's delete this one. Then
we can say switch on String. Let's add them. Manually
clicking on the plus. The first item is
the light feather. The second item is
the golden brown. What we can do is if it
is the light feather, we can make a return node
writing return here, select it and just
drag it into here. I'm just going to call
this one spawn points. What we can do is
we can basically copy paste this down here, connected and just like this. Okay, now we have to do it
for all of the spawn points, but for now let's
just see if it works. And we can always continue. If I go back to the player, now I take the game mode
variable and I say items points, and I say get items spon points. Now I can get the Spain points, depending on the item name. I'm just going to
drag this into here. Then I'm taking the
spawn points and then dragging it into up here. Now we can delete this part because now it is
dynamically added. And if I click on Play
and I buy light feathers, if I buy torches, it is still on the same spot. Let's see what is going
wrong inside of here. So I can see I have written Golden Crown by mistake
and it is Torch. So this is probably the problem. If I click up here,
right, Torch again. If I connect it back in when
I changed the name and I click on play again and I buy the light feathers
and I buy the torch. You can see now it is
working perfectly. Now I can see it's
also spawning in the three rows that
I have chosen. Now let's test and see
if that is working. If we change the settings, if I go to the game mode, set item spawn points. If I just click on
the local amount of rows and I change that
into two rows instead, also for the loop counter. The last index here, let's say I wanted ten items in one row. I write nine here, because remember the start
index is zero, Fycliconplay, I buy
the light feathers, You can buy ten of them. And it's going to stay here, but the 11th one is
going in the next row. Now you can see it
is working perfectly and I can do the same
thing with the torch. The good thing is you
can always delete one and you can place
it wherever you want. You can click Control
Alt to duplicate. It can change it back to
torch like this save. I don't think we need this point point name anymore for this one. Probably going to remove it, but let's click on play again. Now you can see they are working because the
first one was Torch. Now we just check the
first one is Torch, the second one is
Feather, and so on. All of them is
working correctly. Now let's go back to the
Spain point base or this one. Let's remove the
instance Editable and expose on spawn because
we don't need it anymore. Let's go back to the
play controller. I'm going to delete all of this and let's move
all of this together. I'm just going to
create some rear route notes to arrange
this a lot better. All right, so now
I have rearranged everything and just made
reroute notes. It looks better. So what we need now is all
of the other respond points. Let's just finish this part. Let me delete the
first one down here. Let's just start
from the beginning. What you can do is just drag
here and you have to make, obviously to the amount
of items you have. Right now we have
ten. I'm just going to down, this is 234. We basically have to
make a larger map or maybe we need to
make more space. Just go ahead and
copy eight of them. All right, now I
have ten of them. Click on the first one, make
sure it is the first item. You can always go
over and check out here which ones you
have in which order. The first one is the
light feather. Then Torch selecting the first one
as light feather, again, we need to have the
items enumeration, We need to add the
items to them. The light feather
is the first one, Torch, and then we
need the ruin of time. The protector. I'm just going
to add all of them here. The last one for me
is crown of evil. Now that I have all of them
again, save all of it. Close it down.
Let's go over here. And then we have to change
all of them here as well. The first one is Torch. You can open this. I'm going to add it to my second monitor. And this one is ruin of time. Actually, it's just
in order here. We can basically just add
it in order. The protector, so on the last one, for me here is the
crown of evil. Everything should
work just fine. Now if I go back
to the game mode, open up the game mode. Let's open it up here. Now I have all of these inputs that I can
plug values into them. Let's duplicate this one again. You have to make one for
each of them, for example. The next one is ruin
of time spawn points. Just go ahead and make all of them and connect
them here as well. This is the last one for me. The last one is the crown
of evil spawn points. I'm going to go ahead
and add that in as well. Again, just making
sure that everything great, rearrange them like this, that should be just fine. Okay, now that we
have this added, let's go to the
player and also make sure we don't need to do
anything inside of here. In the player here
actually get items, spawn points, we need
to do it here as well. Go ahead and click on the
plus a couple of times. Once again, take a look at your arrays here and just
rename them accordingly. The third one is Ruin of Time. Make sure you have spelled
everything correctly because this is going to be taken as
well from the data table. Name ruin of time. The other one is the protector. I'm just going to add
all of them again. Again, this is the
last one for me, the crown of evil, and I hope I didn't
misspell any of them again, just to copy this
a couple of times. This is 678910. So now we have all of them. Just go ahead and plug all of
them into here once again. And this one is the
last one for me. Then go ahead and
connect all of them. This one is the last one. Just make sure you double check. If you have a mistake
here, just double check here that you have
done everything correctly. Double check that you
are plugging all of this correctly in, like
this together. And also make sure
that you have, in the set spawn points that you have plugged all
of this in correctly, you have spelled
the names correctly inside of the enumeration
in the items here, they are corresponding
to the names that you have inside of the
data table here. Just make sure all of this is correct because that is
very, very important. Everything should be just fine. Now if I go back to the player,
everything should work. If I click on play, now I buy something. Let's just test all of them. If they are spawned, it means they are working. Now I need to make
the map a bit bigger, but we can do that later. But now you can see I can spawn the rose I have
only for 20 items. So you can see it box
if I have above 20. But I will increase the number
to a lot more later on. But as you can see, I
can buy 20 of each item. It looks really good. Now now we have items spawning to the amount
of items we are buying. Everything is calculating correctly, everything
is perfect. Now let's close it down. I'm going to rearrange
this as well, and we can jump on
to the next lesson.
81. 8.17 Item Cost Structure & Data Table: All right, so now what
we are going to do, we are going to increase
the prices every time you buy something
here in the shop. You can see every time I
buy something in the shop, the price stays the same. And this is not usually the case in a idler game or clicker game, because it needs to be
more and more difficult else this will be
really bad game design and it will be a flat game, so we need to
increase the price. This is actually also what
happens in Cookie Clicker, for example, if you
haven't tried it before. So for example, if
you buy more cursors, you can see the price increases and it gets more difficult. So we need to do that
as well for our shop. We need to change
the static price. Let's close this down. Now for this, I want to make a new structure containing
all the prices. If you go back to the blueprints,
open up the structures. Let's make a new blueprint
structure for this one. I'm going to call it item cost. Now let's open up this one. What we basically need to do, we need to specify the
item cost for each item. I'm going to change
this to an integer. The first one we can
call light feather cost. You just have to list all
of the items you have. Now you can go to
this enumeration. If you don't remember the items, you can always just have
it here on the side. And you can go ahead and write all the names inside
of the structure. Add a new variable copy
this one past it in. Add a new variable, copy
this one, paste it in. I'm going to do it
for all of them. All right, this one is
the last one for me, and I'm going to
add the last one, and now we have all of them. Let me close this one
down and save everything. Now what we need to do, let's create a data table
from this one. Always nice to have one. Let's right click,
go to Blueprints, make a miscellaneous
actually data table, and select the Item cost. Click Ok. Call a DT item cost. Let's save everything now. We have to go to Google Sheets. Over here in Google Sheets,
we had this before. Let's create a new one. Let me just duplicate this one. Duplicate this. Let me just call it down here, DT item cost. Now what we need is, let's just delete all of this for now. What we need here
in this data table is the cost of each item. The first one is the
light feather cost. For example, item number one will cost
something like ten. Item number two will
cost something like 15. Item number three could cost
something like 25 and so on. And let's just write all the
names for the items here. I have now written all of
them down, all of the items. Now you have to specify a price for all of them. For
example, this one. The first item could
cost ten for the torch, it could cost 15. Maybe 2030, 40.60
let's say 7510125, and maybe like 150. Again, it takes time
to do all of this. I'm just going to select equal, take the first one times 1.2 maybe just go ahead
and drag a couple of them. Now you can see how powerful this is because you can
create formulas in, in Google sheets and you can actually import
these numbers which are basically done by formula for your game,
and you can use that. This is also what I used in Farm Tail when I developed it. Let's reduce the amount of decimal places because we really don't need
decimal places. Let's remove all of them. Yeah, we can do this. Click
drag also for the numbers, the amount of item spots, it really depends on how
many items you can buy. But for this game, let's say you can buy 50 items. Item 50 costs this, we can just drag it to item
50, something like this. You have to do it for
the rest of them. I think I can do it
like this. Yes, I can actually select all of them here and I can drag
over here like this, and everything will be
just fine like this. Okay, now I have all
of these numbers. You can see how quick it is
when using a data sheet. So now I can click on File, click download,
download CSV file. Now for this, we can go ahead again and change the
name of it like this. Now I can go back to the engine. Inside of the engine, let's
go to the data tables folder. Let's click and drag
this into here. It will update all of the
information as we can see here. Now we are ready to use
this. Let's save all of it. Before we end this, let's create the library function as well. I'm going to open it up
just to stay consistent. I'm actually going
to rename those to F in the beginning because I usually do that for my
functions like this. Okay, let's make a
new function now. Let's call this
one, Get item cost. Now the item cost depends on how many items
we have bought. Because as you can see here, if we go back, it really depends on how many
items we have bought. Because if we have
bought one item, we need to get the
item two cost. Here. If we have bought
eight items already, we need to get the
cost of the next item, which is item number nine, instead of having
it as a string, as we usually did for
all of them here. Actually we used
an integer here. Let's use an integer
here as well. Let me add an input integer. Let me call this one
amount of items bought. Amount of items bought. We already have that information inside of the player map. What we can do is we don't really need to have this number, but we need to add one to it. Because amount of
items you have bought, let's say you have
bought three items. Realistically, we want to get the price for item number four. You wouldn't use this number, but you need to add
one to it because you need to have the next, the price for this one plus one. And then we can say get
data table row like we have done all the
way to get a table row, we need to use the
item cost data table. Now we can plug this into here, but now you can see they
are not compatible, but you need to transfer
it into a string, two string, and then
from a string you can convert it into
a name variable. So go ahead and connect it. Now we can make a return node, adding a return, adding
this into here and calling this one item cost info. Remember to click on it and
make it into a pure function, because again, we're just
getting information from it. Now, let's just test it out
before we end this lesson. Just so we know that it
is actually working. If I go to the blueprints
game mode, for example, here in the graph I can
say get item cost info. And here it is. And we
can use it as we want to. Okay, let's do this, compile, save, and let's move
on to the next lesson.
82. 8.18 Get Item Cost Function: Now what we can
do is we can make a new function called
get item cost. Let's try to do that inside of the player because it
would make the most sense. Because here you have
the amount of coins and we are working with
coins inside of here. I'm actually going to
make a new function. I'm going to call this
one Get item cost. Let's try to see what
we need to do here. Again, I'm going to
change it into a pure because we're just getting some information for
the get item cost. We just made this data
table and function library saying get item cost and
we can use this one. We need the information of how many items have
we bought so far. Remember, we already
have this map. So we can easily do
that by saying find. Just like before we need to
find the corresponding item, we actually need the item name. We need a variable
inside of here. Now, instead of only
having the item name, let's actually just
click up here. Because I know later
here if we break this, we also need to select the item price If I
just make a return, so you can actually
see what's going on, I make a return node here. We need to return the
cost of the item, because this is the whole
goal of this function. We need to know the item cost. Now we need this depending on, let's make a select node here. It depends on which item we are talking about and we
can plug those in. But the problem is we can't
plug a string inside of here. Because if I make a string, now I make a string and I try to plug it in,
it's not compatible. I think we actually need to
add the enumeration that we created to our item structure or to the structure
of the item info. Now, I said before, we might be needing it inside
of the item info and I think we actually do. Let's actually do that now. This is very easy because we already have
everything we need. If I just remember
in the enumeration, you already have this
items enumeration. Let's go to the structures, open up the item info. And the reason why
we need to add it inside of here is over here. I can just say item
here, item info. And I can just add
the item like this, because now we have the item name and we also
have the enumeration. Let's add the enumeration
to this structure. Let's go over here. Add a
new variable called item. Let's change this to
the item structure that I created earlier. Compile or just save, let me just move it up
here below the name. Save all of it again. Now what you have
to do is you have to go back to the data table. You have to open
up the item info. Now obviously you
have to add here a new column to the right
and call this one item. Just copy paste all of this over here, and now you're done. Just go ahead and download the CSV file and
rename this one. Now I already have this one, so I'm going to delete this. I'm going to rename it
to item info and then I'm going to go back to
the engine inside of here. Let's go to data tables, and let's drag this
one into here. And now we have all of
the information we need. Okay, let's save all of it. Now let's go back to the player. And what we can do is
we can break this down. Now we can add the M name. We have that, let me just
move all of it to here. Now we can add the item
name. That is done. Now we can plug this into here. So this is the amount
of items we bought. So it's going to automatically
find the next item price. Because inside of this function, remember we added one to it. So it's automatically going
to the next item to take a look at how much it
costs. So now we have this. We are going to select
the price of the item, depending on which item
we are talking about. Now that we have
this enumeration, we can just click and
drag it here and add it. Now we already know what
item we're talking about because we have defined it
now inside of our data table. In the data table we know which
item we're talking about. It's going to
automatically select the correct value depending
on what the enumeration is. Just go ahead and connect
all of those together. And it's automatically
going to select a value depending on what the value
of this one down here. All right, we are finished
with this function. Now, before we end this, let's go over and actually
make something a bit better. If I go back to the game mode. Remember we did all of this inside of the set
it spawn points. Actually, we already used
the item enumeration, but in the get it spawn points we used this switch on string. We can actually make
it a bit better now that we have
the enumeration. Let me just delete this and say actually change
this one to items. Go ahead and select it, This is the item name, That is fine. We can say switch on, we have switch on enumeration instead of switch on string. It's a lot easier because
it automatically gives you all of the values that you have written down inside
of the enumeration. Again, just go ahead and add it. Now you can see during
game development, there are some things you
might need in the future. For example, I didn't want to add this enumeration before, but now right now, it makes a lot more sense
to have it in the game. It's always nice to go back to your previous mechanics
that you have done and add things
that are better if you begin to need them
during development. Now that we have get
items, one point. Remember we also have
to go to the player. So if I open up the player even graph because
now you have an era. Because remember, this is the previous problem we had before. We can't add a string
to an enumeration, but now we have the enumeration
inside of the structure. We can just drag it into here. Let this pin and go
ahead and compile. Just go ahead and make it
more structured like this. Now if we just click on plate
to test out the game to see if everything is
working as I can see, everything is working
just fine like before. Okay, now this is a lot better. We have made our new
function get item cost, and we can use that to switch
out the cost for the item. Let's move on to the next one.
83. 8.19 Increasing Item Cost: All right, welcome back. So now we are ready to
update the item cost. The item cost is displayed
inside of the UI. Let's open up the shop item
card in here for the price. Let's go to the graph. So far what we are doing is we're just setting
the price to be static here in the
event construct where we set the price. Let's do that again
inside of a custom event, just like what we have been doing for the amount of items. Let me just right click here, make a new custom custom event. Let's call this one
update Item Cost. Now the Item cost, the goal here is basically just
to set the text. So I'm just going to take the item price set
text just like before. This is ultimately
what we need to do now for the item text. Again, it depends on which
item we are talking about. Let me just right
click here. Said item cost because now we have created this function library. We can take this and
break this down. But now you can see the problem now is we don't know
which one to use. Remember, instead
of using this one, we just made one
inside of the player. Let's use this one instead. If I take the player pawn and I take this here and
say get item cost, we have this function
from the player. Now we simply just need
to plug in the item, because we have done
all of this inside of the previous lesson
where we select this, depending on which item
we give it. Let's go back to the item Cod. Let me just delete
this one up here. The item info, we
have that already, so I'm just going
to plug that in. Now. We have the item cost. Now you can see how super easy it is to get the
item cost like this. It also looks a lot cleaner when you make
things into functions. Let me just rearrange
all of this here. Now we have the item cost. Now instead of having it set
as a static value up here, I'm just going to delete it. Click on this one and hide
unconnected pins up here. What we can say is
update item cost. And basically just call
the function that we are, the event that we
created down here. So update that one as well. Okay, so that is working now. The problem is we also need to update it like
the price as well, for all of the other items or other places we have
used the old item cost. Because if I just
highlight this, if I just right click
this item info, remember we have this item cost or coins cost inside of here. And we don't really
need it anymore because we are getting it from this one. What we can do is we can right click this, Find references. And I'm going to click on
the small icon down here, because I need to find
the references in all of the blueprints.
Clicking on the first one, what I'm doing right now is
just taking a look and seeing where I'm using this coins cost because I need to switch
it out for this one. Again, let's take the player, say get item cost. Plug in the item which is
this one. Plug in it here. Instead of using this item cost, we can use this one
instead. Let's delete this. You have to switch
it out because this is the correct item cost
you are using right now. Let's go back to our references and let's click on the next one. Doesn't show anything
because this is just the item name.
Click on the next one. Again, this is the
item cost again. Actually, let's see
if we can copy this. Let me just copy this so
I don't have to write it time again on the item. We already have that
information here. Plug it in, connect
it, Delete this. Let's just put it
over here, compile. Let's open up the references. Once again, click
on the next one, nothing here. Click
on the next one. Now we are inside of the player, so we can just
take it from here. Get it. Cost. And
the item is here. And the cost, we can just
plug it back into here. We don't use this
one. Click on it. Hide unconnected pins like this. Compile. Go back to the references again.
Click on the next one, Nothing here. Click on
the next one again. And here we don't use
the item cost either. Now we can click on Plate
to see what happens. Now if I click on By, you can see the item
cost doesn't update. That is because of
course, we need to call this event
update item cost. This makes sense
whenever we buy an item. If I go to the
player and let's go to this one purchase
item, Let's call it here. Let's call it whenever
we have added to this map and we
updated the item amount that we have bought
before we update the color of the buy
button or by text color. Let's actually add it here. If I just drag from here
and say update item cost, let's connect it like this. That should work just fine. Remember this pin is from the shop item because we
had a reference from it. And let me just
click on this one. Hide unconnected pins,
compile, click on play. Now when I buy, you can see
the item price is increasing. It is increasing
depending on what I have written inside
of the data table. Now, just to make
sure, let me open up the data table and see if
I've done things correctly. Now, item number 15
should cost 128. Item number 15 costs 128 and that is correct.
Now you can see, and that should work
for all of them. So this last one, item number 11, should cost 929. Item number 11 is this one, for the last one cost 929, so that is correct. Now we know this is correct and it is also
calculating correctly. Because you can now see if
you click on the last one, it should subtract 929. And if we press here,
that is also the case, everything is working just fine. Let us save everything, and let's move on
to the next one.
84. 8.20 Designing the Item Tooltip Widget: What I want to do next
is when we click on Play and we hover the
mouse over these cards. I want to have some, a
tool tip that shows you how much DPS you will get or damage per second you will
get when you buy this item. Let's go ahead and
create a tool tip. Let's right click here in the UI and create a
new widget, blueprint. Let's call this one WB tool tip. Tool tip, like this. And
let's open it up now. Again, we need to add
a canvas as usual, before we start designing. Then I think I'm just
going to go in here. I'm going to copy this one, this overlay and this image. I'm going to control C and
control V inside of here. I'm going to click up
here on the fill screen. And again select desired
on screen instead. For the anchor point sensor, it right 0.5 in the
alignment for the x and y. Then click on Size
to content as well. And position x and
Y should be zero. Y zero, now it is in the middle. Okay, now let's
start designing it. I'm just going
ahead and deleting this image as well as
this horizontal box. I'm just going to drag
the text up here. Delete the horizontal box. Now for this one, I'm going to reduce the size of this text. I think it's too large, maybe. Let's try 18 instead. For the shadow offset. Let me write two instead here. Okay, now for this image, instead of having the image
being a certain size, I'm just going to write
32 which is the default. And we can just size
it to the content inside out of this one.
Let's start with the text. For the text, what we need
to say is, for example, each torch gives five DPS. That's what I wanted to say. Now instead of just
having it as a text, I actually want to
add a vertical box because I need some
other text beneath it. Let's add a vertical box. Add the text into this one. And just go ahead and control D to duplicate it down here. I want to say apparently doing, for example zero DPS up here, it's going to tell
you how much DPS, this item it gives you. And DPS, by the way,
if you don't know, is damage per second. So how much damage per second is this item going to
do when you buy it? How much are you
doing currently? This is when, for example, 15 of those, it should
say 15 times five. And it will tell you
how much DPS you are doing for the color of it. I'm just going to copy this
color that we have here. Paste it to this one. And paste it to
this one as well. Now I think I'll give
it some space as well. For example, here we can give it a spacer between the two texts. Let's give it a space
of ten and the Y. And also let's give the
vertical box some spacing. Let's write 30 and the padding, so we have some spacing
now for the DPS. I also want to change the text color because
I think it looks better if we change how much DPs like the text color here, because it becomes
easier to read. Now, we can't really
do it with one text only because else it will change the color
of the whole text. Instead, what we need
to do is we need to duplicate this
one by clicking control D. Let's add it
into a horizontal box, because we need it to
be beside each other. Adding those two
to horizontal box, I'm going to delete the five DPS from this one, from
the other one. I'm going to delete
all the other text except for the five
DPS like this. Remember to add a space here. So I click on this one ad space. Now this is what it looks like. Now you can see the space
is a bit too large. I'm actually going
to delete the space, and I'm going to add
a spacer instead, because now we can control how much space is
between the characters. And I'm going to
write four in the X. I think that
looks a lot better. Let's do the same
thing down here. I'm going to just
duplicate this one. Actually, delete
the one down here. Pull it down beneath
the spacer like this. Then we can write, for example, zero DPS here, down here. We can write currently
doing zero DPS. For example, I want to
make sure that the, this horizontal box is
aligned to the middle as well as this other
horizontal box aligned to the middle as well. Now let us change the color of the five DPS or the
DPS text up here. I'm going to change it to
something purple like this. You can try and find the color you like, maybe
something like this. As for the saturation, I don't want it to
be too saturated else it's a bit too
difficult to read. I'm going to set it
to something like 0.42 That's for the
volume, one is fine. Click Okay, This is
a different text. Now you can give it a
bit more saturation. For example, 0.445 You can copy this into the
other one as well. Now what I also want
to do is change the shadow color beneath it because it
doesn't fit anymore. I'm just going to copy this
up here based on those two. Change it to be something
very dark like this. Maybe 0.4, something
like 0.4 the coke. Then go ahead and copy this past the shadow color
and take a look at it, and I think it
looks a lot better. Now, let me just change this
one up here to 0.4 instead. In the saturation, I'm just going to copy this
color down here. And I'm going to copy
the outline color down here as well. Now you can see it's
a different color and it's a lot easier to read. I believe we are finished
designing this one. Let's move on to the next one.
85. 8.21 Updating the Tooltip Information: Now let us go ahead and update
the Tooltip UI over here. Let's go to the graph and actually update the information. I'm going to delete all of this. And let's right click
once again and make a new custom event called
update tooltip UI. Now for this one, what
we basically want to do is we want to change
the text of those. The first one, see here, it says the name of the item. We need a dynamic value here, we need the name of each item. Click on this one, I'm just
going to call it gives PS. This text up here. What I'm
just going to call it is how much DPS is this
item going to give you? How DPS is this
item going to do? Or how much you're
going to do up here. I'm just going to
call it gives PS. This one I'm just going to call it the same, gives DPS amount. This is the amount down here. I'm just going to
call it doing PS. This one is PS amount. Okay, let's compile
and let's say, let's go back now to the graph. Let's start with the
gives P, the first text. We just want to set text
as usual like this. Now remember what
I said earlier. Previously I said that if you have a dynamic
text like this, you need to use a format text. Let's write from here
and say format text. Let's just write
the same sentence. It says each to give. What we need to
write here is each. And then we need to open the curly bracket because the
torch is a dynamic value, we're just going to
say item name and close it with the
curly brackets enter, you can see an input appears each and the item
name gives like this. And now we can plug
in the item name, we actually need the
item information. Now to do this, let's
just add a pin here, change it into the item info
structure, call it item. Now we can take this, we can break it, and we can take the item name and
plug it into here. And it's going to
update correctly. Okay, that is finished. Let's look at the next thing
is this amount of DPS. Let's take, gives PS amount
and set text once again. Now again we basically need a format text
just like before. So go ahead and take this. Now instead of saying this, we can say EPS amount
and we can say DPS, the number here, and then
the text DPS afterwards. Now we need to plug in the DPS amount. Now
we don't have that. We actually need to add it and we need to add
it to the item, because each item we buy should have its
own amount of DPS. Let's go to the
blueprint structures and let's open up the TM info. Let's add a new
variable called DPS, or damage per second. That is up to you.
Change it into a float, Save, save all of it. Now remember you
also have to add it to the data table
through Google Sheets. But for now just I'm just
going to open up the M info. You can just write
whatever you want here. I'm just going to write 10.20
and 30 or maybe like 50. I'm just going to write it
for the first three just for testing. Really
need it right now. We just needed the value
over here in the item info. Now you have this DPS, go ahead and plug it into here. And that should work just fine. Now for the rest of it,
let's take the doing DPS. Now. It is the text down here. It's going to say
currently doing. Now you can see
here we don't have any dynamic values and we don't really need to
change this text. We actually don't need
to manipulate this text. We only need to change this one. Let's go back and take the
one called gifts, PS amount. Instead, set text. We need to set it to the amount. I'm just going to copy this one. And this one is going to display the total amount of DPS for
this item that you can do. I'm just going to write here total amount of DPS and
then just DPS afterwards. I didn't connect it.
Now, the total amount of DPS depends on how many
items you have bought. And remember, we already have
that inside of the player. We need a reference
to the player. Let's do that. Here it, player character, by the way, try to do this
yourself if you can. Because I think you can do it. We already have the variable, the map variable inside of the player which
you need to use, let's say it player reference from the
blueprint interface. Go ahead and connected. Now
it was called Item Spot. Go ahead and get this map here. Now from this map, we need to find the item we
are working with. I'm going to drag
here and say find. And we need to find the item. And when we find the item, it's going to tell us how many of this item
we have bought. Let's just drag this one
all the way over here. Now we have the amount
of items we have bought. To calculate the total DPS, you have to multiply the amount
of items you have bought with how many DPs or how
much DPS each item is doing. Let's take this one and multiply it by the amount of
PS each item does. And then with that we have the total amount of DPS
we can plug into here. Go ahead and plug this
into here as well. Now we are actually finished, so go ahead and click on
this hide unconnected pins. Go ahead and double
click on these to make re art notes and
organize your code. All right, now that
is organized and with that finished go ahead and
compile, save all of it. And now we are finished with
updating the dual tip I.
86. 8.22 Displaying the Tooltip Widget: Now it is time to display this tool tip widget
that we have created. In order to do that, we have to do that inside of
the shop item, Cod. Because remember when
we click on play, we want to have this
tool tip appear. Whenever we hover
over these cards, it's actually inside of
the shop item. We do that. Let's go into here. I want to display this widget. Whenever I hover over
anything over this card, I'm just going to click on
this overlay and do it here. This means that wherever we hover on this
card, it will appear. Click on this overlay. I'm going to go down here in the Behavior and
click on Advanced. Down here you see this one
called Tool Tip Widgets. Go ahead and click on Bind
and create a binding. Then go ahead and expand this. Now we need to get the
widget that we created, the shop Tooltip widget. We haven't created
a reference to it, because usually we create references to UI inside
of the play control. However, for this widget we haven't really
created anything. I don't want to create it inside of here like we've been doing. Because the, it is not something
you can open and close. It's just something that appears whenever you hover
the mouse over cards. Instead of doing it over here. What I'm going to do is I
usually make my events that I inside of my games
called initialize layer. Inside of this event,
I add everything I need that should happen
whenever I open the game. For example, this tool tip
widget needs to be created, Let's say create widgets. And go ahead and select
the Tooltip widget, this one Shop tooltip. And go ahead and promote this to a variable called shop tooltip. For example, shop tool, Okay. Now that is created, and also
remember to add it up here. I'm going to do that before I create the cards. Now
it doesn't really matter. But just to stay clean here. Initialized player. Now we're calling
this event down here, put in connected, whatever
I need to happen. When I open the game, I'm going to add it to
the initial player event. Now we have a reference
to this Tooltip widget. So what we can do now
inside of the card, we can get the player controller,
get player controller. Then we can direct
from here and say get player controller reference
from the widget blueprint. Now we can take this
one and say tool tip, and we can get this
widget we just created. Now for this widget,
what we need to call is, if I go back to the widget shop, tool tip inside of here, remember we made the
update tooltip UI. Let's call this one update
tool tip I connected. Now it needs an item
because we use that to update basically all
the information we have. That because we are inside
of the shop item Cod, and we have created this
item info previously, which we also used inside of here to update item information. Let's take this one
and plug it into here. And then connect this. Also, remember to connect
this widget tool to Putt to the final node here. Again, you can
double click here. They organized like this. Okay, that should work. If we compile and
we save everything. And if I click on Play, you can now see it actually it displays with the correct
name for the item. You can see it says each run
of item or each run of time, and the protector protect
each king helmets, each king's crown and so on. It now displays
the tool tip with the correct information as
well. Now there is a problem. Now if I click on play
again and I buy something, you can see it says zero DPS and nothing is
really displaying. Now for this one, let's
try to close it and let's actually check the data table if we have written
things correctly. If I open up the item
info, the first DPS, the light feather should
be 1020, then 50. And if I click on play, and I check the
first one should be 1,020.50 And I can see
nothing is displaying here. But you can see here, every
time I buy something, it actually displays correctly. If I move my mouse and
hover over it again, and it says 20 DPS. Let's take a look at
where it goes wrong. If I open up the
shop tools widget, the information
here it gives me, first one was called gives DPS. This one gives DPS
amount. That is correct. Let's take a look at
the gives DPS amount, how that is being set. Let's also check the
other part of the code, and here's actually
where it goes wrong. Because I use the
gives DPS amount, instead of doing DPS amount, that is the wrong thing. Here, let me just delete
this one and compile. Click Play and if
I hover over it, now it displays correctly. This was because I said
the text wrong here. Text doing EPS is the correct one and gives
DPS was correct as well. Okay, now if I buy something, you can see it still display
zero on the currently doing. But if I move away from
it and move to it again, you can see it
displays correctly. If I move away, move to
it, it displays correctly. In the currently doing 30 DPS, we need to actually update
the currently doing DPS like another place as well, because it's not
updating instantly. What we can do is I can call this update toolpI every
time I purchase an item. If I close all of its, I go back to the blueprints. Open up the player here. We made this one purchase item. What we can do here with the purchase item is I
can just update it here. At the end, we need
the player controller. I'm going to take the player
controller and I'm getting the tool tip widget
that we created. Then let's run the
update tooltip UI every time we
purchase an item. And what is the item? It is this one that we
have input it here. Let's take this and
plug it in again. Just organize it like this. And let us compile and click on Play and
see what happens. Now if I buy, you can see it updates the amount of damage per second instantly and it is also updating correctly depending
on the GPS we are creating. Now to finish this up, open up your Google
Drive inside of here, let's find the level
info, item info here, item info and after
the coins cost. Let's add DPS. For the TPS, I'm just going
to write for the first item, it's going to do five DPS and
then let's just say equals. I'm just going to make
random numbers multiply by 1.5 I'm just going to take
it all the way down here. I'm just going to remove all of the decimal places because
I don't need them. And we can do it
something like this. You can also even
say multiplied by 1.8 We actually do
more damage like this. Let us now go ahead and
download this CSV file, and remember to rename this one, renaming T item info. Go ahead and open
up the project. Go to the data tables, then go ahead and then go ahead and import the
item info to here. Let's check the
item info to make sure that TPS is
there. And it is. And so now you can see each item has the correct
amount of DPS displayed. And if you buy something, it's going to display the
currently doing DPS correctly. Obviously, we are
not really doing any DPS right now because we
don't have automatic damage. But at least our system is now working so we can
continue the course.
87. 9.01 Automatically Applying Damage: It is now time to automatically apply
damage to the enemy. And this is usually
what it's done in clicker games when you buy this. And it does damage per second. It should do it
automatically instead of you keep clicking the enemy. Let's go ahead and do that.
Let's do that in the player. Let's go back and
go into the player. Now we already did something with the damage inside of here. Inside of the player, or
actually it was inside of the enemy where we
applied some damage here. Now let's apply some damage
inside of the player. This is now the
player doing damage. Let us right click and
make a new custom event. Let's call this one Auto Damage. Going to automatically
do damage for this one. Now to do the automatic damage, we need something looping. We need a looping code
that keeps running and it never stops and
is doing damage to. You have something
called a timer. We have something called event. Set timer by event. You also have something called
set tim by function name. Now they are similar. These two functions,
they are similar. Usually we use those when
we need something looping. We use the delay node
whenever we need to delay some code and then
do something afterwards. Remember for the delay node, we use that inside
of the enemy base. If I go inside of here, we use that to actually delay this code because we waited
for the flip to be over. We delayed the code by the
length of the flip book, and then we checked
if the player or the enemy was dead or not. Here we use the delay. If you need something that is looping, the code needs to be looping. It's better to use a timer. We have a timer by function
name and timer by event. Now, it doesn't really
matter which one you use because they are
almost identical. Actually, I use both of them, so I don't really
have a preference. I can show you how
to use them for the T. Let's use the
timer by event first. Let me put this over
here, delay this one. Let's connect this one
first timer by event. You have to tell the timer. How quickly do you want to loop? For example, I want to
loop every 0.1 second. This means the code is going
to run every 0.1 second. The code here is going to
run ten times a second. I'm going to set it to
looping. Now we need an event. I'm going to drag
this down here, right at custom event. Let's call this one
auto damage loop. Whatever code you write, it's out of here now
is going to loop. For example, if I drag
from here and write a print string and it should
say hello and I compile. Now this auto damage, you obviously have
to run somewhere and I'm just going to run it in
the beginning. Play up here. And let's write do damage. Now we are running
this event here. And it's going to run this
timer which loops the code. Compile Clic Play. It actually runs this code
and it's still running. As you can see here, it runs, or it says hello ten
times every second. If I write 0.04 for example, click Play, you can
see it's a lot faster. Now if you are not
strong in math, you can always calculate
it by saying, for example, 1/0 0.04 It means that the code is running
25 times a second. Now a tick, you
might know this one that I always tell
you not to use event. This one very bad one is actually running
at, if you're right, 1/0 0.02 this is actually 50 times this
event tick runs 60 times. This one is actually
not even enough. It's running maybe
0.18 or even lower. As you can see, event tick
is super, super quick. It's actually running like this. The com play, this is the event. You can see the timer is a lot, it's a lot more optimized. You can run the code
not nearly as fast, but you can still get the
same results if I run it by 0.05 This means that I'm running the code
20 times a second. This is sometimes
necessary because if you run the code too slow, it's going to feel like
the health bar is lagging because it's subtracting
health like this. This is if you run
the timer too slow. And we can actually see that
whenever we do all of this. Now the set timer
by function name. The difference between those two is this is going to
loop a function, a function we create out here. I'm actually going to
use this one because Mostly I want to use this one because it
keeps the code clean. I don't have to write or spam my event graph with
random events. I can actually just make a function and it's
hiddens out of there, and it's a lot cleaner
for this function. Let's call it auto damage. Let's also make
this function here. It loops this whatever
name you wrote over here. It's going to loop
this function. Now remember you have to write it precisely as how you
have written it here. For it to work, I'm going
to rise 0.05 or let's actually rise 0.14 Now let's try that. Let
me delete this. Let me delete this as well. Let me connect it,
let's write this, Promote it to a variable, so we can stop the
timer if we need it. I'm just going to call
it auto damage handle, because if you hold
the mouse over it, it says this is a timer
handle or damage handle. We can use it to stop the
code or stop the timer. Now basically this damage, I want to play it up here in the event or begin
play for the player. Whenever we start the game, we start doing the Orodamage. Obviously we do zero damage if we haven't bought
any items yet. Let's go to the Or
damage function here. Just like before,
I want to apply damage and now the damaged
actor is the enemy. And remember we
have a reference to the enemy inside of
the play controller. I take the player
controller and I search for spawned enemy because
we have made it into a variable and go
ahead and connect it. Now as for the base damage, we are going to work with
it in the next lesson. For now, I'm just going to write five and that should
work just fine. Now Flic play. You can now see the enemy is getting damaged
automatically. And it looks nice. But we obviously have to fix some
of the animations here. Now I want to show you
that it feels laggy, if you said this time. Or too slow play, it looks laggy, it
looks low quality. However, if you set
it to something like 0.04 which actually I want to set it to 0.04
it looks a lot cleaner. The lower you set it, the more it's going to
look clean, Like this. You can see here it
goes a lot smoother. However, remember,
the lower you set it, the more you are going
to loop this timer, and the more resources you are
going to use in your game, and the less
optimized it will be. I want to tell you
here that four timers, try to set it as
high as possible without sacrificing
the look of the game. If I think 0.05 to Leggy, I'll set it to 0.04 and I will be satisfied
with that number. Again, you can go in
here and say what is 1/0 0.04 That means my code is running 25 times. That is good. That is fine. A lot better
than the event tick, which is 60 times a second. Okay, now we're finished with all of this and let's move
on to the next lesson.
88. 9.02 Calculating the Total DPS: To apply the correct
amount of damage, we have to calculate how much damage per
second the player has. Because the player can
buy all of these items, we need to put everything
together and then apply it as automatic
damage to the enemy. Let's do that by
creating a new function. And this one is going to be
called update total EPS. First, we need all of the items that the player has bought. Let's take this map.
In order to do this, we have two functions. We have two nodes. We can use one called keys. What keys are, are the
first column here, the string, This is
called keys. If I down and say values, then you can get the
values of those keys. We have keys over here
which are the strings, and then we have the values. Now we need all of the items
that the player has bought, so we need to use the keys. I'm going to take
these keys here. Now we have all of the
items in an array. I'm going to loop
through all of them. For each loop, for
each of those items, we want to know how much
DPS they are doing. For the DPS, remember we
have the get item info, get info that we made from
the function library. Let's go ahead and get
that for the item name. Let's plug it into here. And now we can break this structure. And now we
have the amount of DPS. Now again, the amount of DPS, it also depends on how
many items we have bought from this selected
item that we have right now. We also need to use the values. I'm going to copy
this here and say values because we
need to know how much did we actually
buy from those items. For the values, I'm going
to direct from here and say get because we're already looping here, so I
don't need to loop. So I'm just going
to say get a copy. Which index do you want to get? I'm just going to follow the indexes or
indices for this one, so we get the correct
amount of items for the corresponding item. Now what we can do with this, we can say this is the amount
of items multiplied by DPS. For example, if we
have five of the item, it's going to say five times. For example, ten DPS is ten. Then we need a new variable
to store the total DPS. I'm going to make a new
variable called total DPS. I don't change it into a float. Now what we can do is the
old amount of DPS, los, the DPS we have right now
that we have calculated, we can set that to
the new DPS here. If we don't do this, if
I just move all of this, if we just do this and do
this here and connect it, this means that every
time it calculates, it's actually going to set
this EPS to this number. And we don't want that because we are looping through all of the items and we are basically
stacking all the numbers. And keep multiplying and multiplying and adding
to this variable. Instead of setting it
to a static value, we need to plus
the old amount of the total DPS to this one. And we get the new amount here, and we can basically
set the total DPS here. Now we have the total DPS. And also maybe we might get a number or not really a buck, but display a buck
where it keeps calculating and
maybe the number is displaying wrong at
a certain point. What I want to do, instead
of using the total DPS, I'm actually going to
make a new variable, a local one called
local total DPS. This is a local variable only existing inside of this
function we are in right now. I'm actually going to use the local variable here
to set the amount of DPS. Now remember that
the local variables, they cannot go outside
of the functions. Next time you try to
calculate the DPS, this one is going to be zero. These local variables,
they will be deleted every time you
try to run this function. This is why you can't use this
outside of this function. Basically what we need to do
is when we complete the loop and we have this total
amount of DPS set, we can take this
local amount of DPS and we can set the
total DPS down here. You can do it that
way, or you can basically do it
directly up here. It doesn't really
matter, but I can imagine there is a display
box in the future. If there is not all fine, you can just plug
in the total DPS here instead of the local one. I'm just going to
do it that way. And now we have
the total DPS set and we can save all of it. We can click here, Hide
unconnected pins if you wish to, And again, reorganize
everything. Now that we have
the correct number of TPS that we are doing, let's move over to
the next lesson and finish the oral damage.
89. 9.03 Applying Correct Amount of Damage: Now that we have the
correct amount of damage calculated
or the total DPS, let's go over to the auto
damage function once again, and let's do the correct
amount of damage. Now instead of writing
here or instead of just dragging the total DPS
and applying it here, this is wrong, because you click on play now and
you buy something. And you can see
here, it's not doing damage right now
because we actually need to run this
update, total DPS. Let's actually do that inside of the player when we
purchase an item, because we have to update
the DPS For the DPS, I'm actually going to do that after or before
spawning the item. And let's drag it over. Let's drag in the
update total DPS to make sure it updates every
time we purchase something. And if I click on Play now
and I purchase something, you can see it does
the damage per second. What I want to do now
is you can see here, even though the
damage per second, so for the first one should
be five if I buy one only. But as you can see, it's not doing five damage per second. Every second is
doing a lot more. The reason is we are
running our timer. If I go back to the event graph, we are running our timer at 0.04 We're not running
it one time a second. So as you can see here,
five by the light feather. Now we're going to do five damage per second,
which is correct, but we are running it at
0.04 We actually need to do some division to get the
correct number per second. Let's do that inside of
the auto damage here. What we need to do
is basically to say did just like what we did
before where we said here, remember 1/0 0.04 and
that gives us 25. Basically, this code
runs 25 times a second. We need to divide the total DPS with 25 to get the correct
number. Let's do that. Let's say 1/0 0.04 Here, I'm going to take, just right click here,
divide and choose that one. We are going to say 1/0 0.04 Basically 0.04 we
have that in our timer. Let's actually promote
this into a variable. Let's promote it to
a variable called Auto Damage Tim Time. Now we can use
this one inside of the auto damage and go ahead
and plug it into here. And divide by 11 divided by
the auto damage timer time, which is 0.04 That gives us 25. As we saw here,
that gives us 25. What we need to do is the
total DPS divided by 25, that gives us the correct
amount of damage per second. Now it is going to do five
damage per second correctly. If I compile now and
I click on Play, and now I click on By
for the light feather, it's actually going to do five damage per
second correctly. Just say 75 when it's finished. And it actually said 75 here. Because we loop through
5 seconds and five times five is 25. That is correct. But I can see the number here is displaying with decimal places, and I don't really like that. Let's fix it. Let's
close it down. Let's go back to the UI. Let's open up the health bar. And here inside of the
graph for the health bar, we just plug in the float. This is why it's
playing here with decimal places when
you hit the enemy. Instead of doing that, what you can do is you can
drag from here. If you don't know the functions, you can basically
just write floats. You can try to look
through all of these. But basically what
I want to use is either the floor or the seal. Basically what
floor and seal is, you can hold the mouse over it and you can see what it says. It says that it rounds
down, you can see it. -1.6 becomes -2.1
0.6 becomes one. Either that or you can use
seal. I think I'll use seal. Therefore, this one basically 1.6 becomes two instead of one. I'm going to use
Seal, and you can see it changes it
into an integer. And remember an integer does
not have decimal places. I'm going to hold Alt. Click here to disconnect this and then connect
this one instead. So now we have an integer. And if I click on Play and
I buy the light feather, now you can see it does
five damage per second. It is not displaying
anti decimal places, everything is working correctly. But as you can see here,
all of the effects, I don't want this
effect to happen. Let's jump over in the next
lesson and fix all of those.
90. 9.04 Fixing the Hit Effect: All right, now we are finished
with the auto damage. However, you can see here
we have this effect. I don't want this
effect to be here. So we need to delete
something from the code. As you can see, it's
also not playing the death animation
that is wrong as well. Let's go ahead and
fix all of this. Let's open up the enemy because the damage
is inside of here. Now the hit effect is playing, because every time we
do damage to the enemy, it's going to play
the hit effect. Let's go ahead and disconnect
this and see what happens. I click on play and
buy some damage. Here you can see it
is working correctly. However, the death animation is for some reason not playing. I believe that is because we are looping the code many
times and it keeps. Now if I just copy
this death event and I try to plug it into here, now it doesn't really make
sense because we are going to kill the enemy instantly
every time we click. And as you can see here, that is not the
correct approach. What we can do here
is we can ask, is the enemy dead? Let's try here. Is the enemy dead?
Because we don't really want it to go
through the hit effect. If I just connect this and
I try to click on Play, and I buy a couple of tomes, now it looks correct. And if the enemy dies, you can see the enemy
is dying correctly. Okay, So everything is working. We have disabled the hit effect and everything is working. Now if I click myself, you can see I don't
have any hit effect. So I need to fix that as
well for the hit effect. Now when I click on it, so this is the mouse click, we can add the hit
effect up here instead. And if I click on play, now I hit with the mouse, You can see the player, the enemy hits, but you can also see the
animation is booked. You can see here when I click, sometimes the enemy
stands still. And I tried to do that again. But this one I think
the second one booked that is because
if I click too quick, you can see this one. The death animation had a book. This is because here in
the is dead it's actually playing this death
animation as well for the auto clicker as well as you. When you click the
death animation is basically played two times. And this is going to book the
animation because you keep spamming this timer here and
it never plays correctly. What we can do, this
very simple fix, is damage that we apply. Because we have something
called a damage type, We can basically specify, is it the auto damage
that is doing damage, or is it the click or the
mouse that is doing damage? To do this, very simple, let's go to the blueprints. And here let me just write
Click Go to blueprint class, we can search for damage type. If you just search for damage, you can see it down
here, damage type. Go ahead and select this,
just call it auto damage. Now, we are not really going into damage stuff
inside of here. We basically just need
this blueprint class. You can think of it as working with enumerations
where we have a list basically using this class and an
enumeration type. Let's go back and let's
go to the player. As you can see here
in the player, when we did the applied damage, you could set a damage class, now we can set it
to the auto damage that we just created compile. What I want to do here is I want to play this whenever it is, the auto damage that
is doing the damage. Now what we can do
inside of here for the damage or the enemy, is we can take this damage
type and we can basically search for a name and we
can get the displaying. Now you can go ahead
and print a string and see what it does if I
just disconnect this, put it away, and you can
write a print string. Go ahead and connect it. And
connect this one as well. Just see what it
brings to the screen. If I click on play and I buy
something to do auto Damage, you can see it basically displays the name of the blueprint and it
says Auto Damage. This is what we called
it. I can use this to my advantage by taking this
and search for contains. I'm just going to see if this string contains
something I'm searching for. And if I just search
for auto damage because it is part of the
name of the blueprint. If this damage type that I did does contain auto
damage in the name, I can make a branch here. I can go out and connect this as well or basically
what you can do. You can also go ahead and say if you don't want
both branches here, you can take this
and say bullion. You can basically
take this over here instead and connect this one. You can delete the
other bullion. If the name contains damage
and the enemy is dead, you can go ahead
and play this one. Let's go ahead and
compile and Save. Now you can see if I
click on play and I buy something here, Damage. You can see everything
is working correctly. Nothing is bogging out. Also, if I click on play and
I try to kill the enemy, everything is working
perfectly as before. And if I buy or damage as
well as I click on the enemy, we're both doing something. You can see it's
only playing once. And there is no buck
in the code either. Now we know the code
is working perfectly. Go ahead and rearrange
all of this, and let's move on
to the next lesson.
91. 10.01 Designing the Level Display: What we need to do now is
just like in Clicker heroes, where you can see the level
you have reached up here. We have to do the same
for this clicker as well. Let's go back to the UI and let's add it
here in the main u, over to the side inside
of the main widgets. I'm just going to
copy this part here. I'm just going to click
on this overlay and copy and basically
the whole thing here, control C. And then click on the canvas panel control
V. Just paste it up here. Now for this one we are going
to place it to the side. I'm going to click
on the anchor point and placing it to the right for the offset. I'm just going to
write zero in the X. The bottom upset
is zero as well. Now you can see it's
off the screen, it's actually on the side here. What we need to do is basically the alignment here for the x, we need to push it inwards. It is just writing one
here in the alignment, Now it is in the screen. What we need to do now
is for the position x, we just need to
push it away from the edge of the screen again, just like before, you
can click on this one. If you don't remember
what you have done, you pushed it 30 pixels away. Let's do the same thing
here to stay consistent. Clicking on the overlay, I'm
going to push it 30 in the x offset, actually, -30 else
it will go the other way. And 30 offset from the top. And again 30 from
the bottom as well. I also need some text up
here where it says level. Let's just copy
this text up here, Control C and then control
V. Down here on the overlay. I'm going to put it
above the scroll box. Actually, we need to
add a vertical box, else it will be in the middle. Let's search for a vertical box. Go ahead and add it. Then add the text and the scroll
box into the vertical box. Clicking on the vertical box, go ahead and go ahead and fill it here
horizontally and vertically. And also the scroll
box you need to fill for clicking on Fill here. Now we need to give it
some padding as well, because as you can see, the text is on top of the edges as well. And also for the front size, I think I'm going to reduce
the front a bit more, so maybe writing
24 here instead. Now what we can do is we can basically here
for the scroll box, I'm going to write
zero in the padding, because now I'm going to add
padding to the whole thing. Clicking on this vertical box, I'm going to give
it a padding of, let's start with 50 and
see what it looks like. Okay, that looks good. And also I need to increase, maybe the overlay slightly so I can see what it looks like to the right and left. I don't think I need
to give it that much of a adding to the
right and left. I'm going to write 35 instead. Like this, I'm clicking on these lines to remove them.
To see what it looks like. I obviously need to
add a spacer between the text and the
scroll box down here. Add a spacer of maybe
like 15 and the y. Now we have this
display ready up here. Let's just write level instead. Go at and compile and just
make it slightly larger. We also need to fix the size, depending on how large
the level card will be. For now, everything
is looking good. But let's now go over to the next lesson and
design the card.
92. 10.02 Designing the Level Card: To design the level card, let's do the same method as what we did here with
the shop item card. So let me just right click here, go to user interface
and make a new one. Let's call this one level card. Let's open it up again. Go ahead and add a canvas
panel before we do anything, Also change this to desired
on screen. Now we are ready. What I want to do is basically
the card will be a button because it will be a bunch of buttons here to
switch the level. Depending on which level
you want to switch to, I'm actually just going to copy this button
that we made here. Clicking on this
overlay and button and text and click on control C. Go back to the level card
and control V over here. Now for the overlay,
I'm clicking on Size to content as well for the text. Actually, before I do that
over here for the overlay, let's change the anchor point
to be in the middle and 0.5 in the alignments
and 00 in the x and y. Now it is perfectly
centered for this text. I'm just going to
write one for now. So this is going to display the level as well as
for this button size. I think I'll reduce it slightly, I don't need it to be this wide. Clicking on it, we can
reduce the size in the x. I think I'll
write 100 here. Just make sure to copy this image size and paste
it on the hovered as well and on the pressed as
well. For this text color. I'm just going to change it
back to this default color. So go ahead and copy this color. Go back to the level card and
paste it over here as well. Now basically this one is ready. Let's take a look at what
it looks like if I go back to the Main menu or the main UI. And I click here, and this
one is called the Item list. I'm actually going to
change the name of this vertical box
to a level list. Compile. Now let's search
for the level card up here and drag it
into the level list. And go ahead and
duplicate it a couple of times so you can see
what it looks like. What I want to fix here slightly is the size
of this overlay. If you just push it in
until this disappears here, just try to make it like this, as small as possible, but without bugging like this. Also the scroll bar. I want to start it here at
the edge of this button. So clicking up here, going down the scroll bar, finding the scroll bar
heading for the top. I'm just going to write
something like eight. That is good. I think we need that for the bottom
part as well. I'm not sure right now. But
we can always duplicate this a couple of times and take a look and click
on the last one. And we need that as well.
For the bottom patting. I'm also going to
write eight as well. Actually, it needs less. Let's write instead of eight, let's write something
like five instead. We can always come
back here if we need to change more
things with the UI. But for now, everything
is looking good, and if I click on play, I hope the mouse over them,
everything is working. What I can do now is
just go ahead and delete everything so it is clean and we only have
this level list. Compile, save all,
and let's move on.
93. 10.03 Setting the Level: Let's now go ahead
and dynamically change this level
for this button. Now this is going to be very
easy because let's click on this text and let's just rename
it to text level compile. And now let's go to the graph. Now we're going to
do it just like before with the shop item. Whenever we add it to the list, it's going to change
this information inside of the event construct. It's going to basically update the item cost and all
of this for this one, again, let's take
this event construct. The only thing we need to
do is basically set this the level we need
to set the number. Now as for the level, let's just make a
new variable here, and let's use an integer. Let's call this one level. We're going to give
it this information. Whenever we create this widget, you can always go back to
the player controller if you don't remember what you
did with the item shop. You see here if you go down, what we did is basically create
this item info variable. And we clicked
expose on spawn and Instance Editable and we could
feed information into it. We're actually going to do
the same thing here for the level instance
editable, expose on spawn. We can basically just
click and drag this into here like this and we're
actually finished here now. We can give this some information whenever
we spawn the card, and we're going to do
that in the next lesson.
94. 10.04 Unlocking the New Level: All right, now let's go ahead and give this some information. Again, we are working with UI, so I'm actually going
to create this in the Player controller down here. Let's make a new custom event. And let's call this
one unlock level. We can use this one to
unlock the level or display this level
display over here. Whenever the player
beats an enemy. This unlocked level, it basically creates this
widget to the side. So we can see the level. Basically the button right now, it has an era because I connected this
without any information. If I click on Play, basically a button appears whenever
you beat a level. And this is what we want to do. It basically creates the widget. Which widget does it create? It is the level card
that we need to create. As for the level, we can tell it later which level to unlock. So I'm just going to click
and drag this into here. I want to add this
button to my level list. If I go back to the UI, open up the main Ui, we call
this one VB level List. This is where we want
to add the card. If I go back to the
play controller, I can see what I have.
I have this WB main, so I can add it from here and search for the level list.
Go ahead and click on it. Now we can say add two, and you can choose this one. Add child to vertical box. Basically, you can add this
widget you just created to your vertical box and
go ahead and compile. Now we are starting
with level one. And level one should
be there by default because this level
we are in right now, let us just unlock level one by default here in the
Player Controller. Whenever we start the game, I'm going to write unlock level and we can basically
just write one here. We're unlocking level one by default and clicking on play. You can now see level one is unlocked and it is displayed. And we need to unlock all of the other levels whenever
we defeat an enemy. Let's go ahead and do that
inside of the game mode, because in the game
mode, if we go back, it's a long time since we did
this here in the game mode, but here we made this
increment current level. Let's unlock the
level here instead. Whenever we increment the level and we haven't unlocked it yet, we can go ahead and unlock it. Let's call it, it is inside
of the player controller. So we need the player
controller here. And we can search
for unlock level. And go ahead and take this here. What we need to do
here instead of just unlocking this
current level. Because we might actually
be playing a lower level, if we want to go
into a higher level, we don't want to
unlock it again. Imagine if I'm playing here
and if I'm at level five, but I choose to click on level one again and I
play the level one. I don't want to unlock again level two because I
already unlocked it. We need a new variable here to save the previously
unlocked level. Let's make a new
variable and call it previously unlocked level, make it into an integer. Here what we can say is, is the current level, is it higher than the
previously unlocked level? For example, if we
are at level one and the previously unlocked
level is level four, we don't really need to
unlock level three and so on. Again, because we are at level four already, our max level, let's make this branch if the current level is higher than the previously
unlocked level. If we have reached
level five and we unlock level four
earlier, if that is true, we are going to take this
previously unlocked level, we're going to set it to
whatever the current level is, which is now level
five instead of four. And we can just plug in
this information down here. Now if I compile and I click on play and we can
defeat this enemy. You can see level
two is now unlocked. If I defeat this enemy as well, level three is
unlocked and so on. So now all of that is
working correctly. However, again, we haven't
really coated the button, so we can't go back in level. And we are going to
work on those next.
95. 10.05 Setting the Current Level: What we want to achieve
right now is we want to prevent the enemy
from spawning, automatically changing
a level like this. What we want to do is
we want to manually change the levels when we
click on those buttons. Let's go ahead and
work with that next. Now here I am inside
of the game mode, and let's just push
this a bit down. Here I am beneath the increment current event
that we created previously. What I want to make here
is a new custom event. Let's make this, let's call
this one set current level. We're going to use
this custom event whenever we click on those
level buttons out here. We're going to set the level manually setting
the current level. Obviously we need
the current level here and we have to set it. And we have to plug
this into the events, because then we can set
it manually other places. Now we are setting
the current level here for the current level, I'm just going to say a level. Setting the level we choose
to the current level. Then we, we, we change a level. We want to make sure
that the enemy that is in this current level
we are in is removed, else they will spawn
on top of each other. Remember it is in the
plate controller, so I'm just going to copy
the plate controller here. Get the spawned enemy variable. Right click and say convert
to a validated get. Because now we can
say if it is valid, we can go ahead and
destroy the Acta. Then after we destroy the Acta, we want to spawn the new enemy. Basically, I can actually
copy this up here. I can just copy it, paste it, and connect it like this. Now if the enemy is
not valid already, we can just go ahead and
spawn the new enemy. Because the only reason we added this part is to make sure that the current enemy
is destroyed and current enemy is not existing. We can just go ahead and
spawn the new enemy. Now we are actually able to set the current level
using this logic. So let us compile
and save everything. Now let us go back to the UI. Here in the UI, if I click on the level card and I
click on this button, go down to the button and click, click, click on the plus here
to create an event here. Whenever you click the button is called by button and
it's not really correct. I'm just going to
rename it button. I'm going to call
it level compile. Let's go back button level. Whenever we click on it, we
want to change the level. We want to call this event
here in the game mode. Let's go ahead and do that. Let's say right click here
and say get game mode. Then let's drag
from here and say get game mode reference, the one from the
blueprint interface. Let's strike from
here and say set current level because this
is what we called it. Now we already have
this level information because we plugged it in here. Let's just plug it in like this. Let us compile. And
let's click Comp and see what happens when
I kill an enemy. I kill the next one as well. Kill the next one as well. Now let's see if I
can change the level. If I press on two, I can
change it, press on one. And I can see I can
actually switch between the levels and
everything is working. The timer is resetting
every time I switch the levels, the
thing we want to prevent. Now, you have a bug
here, for example. If you kill the
enemy in level one, you can see it automatically
switches to level two. I don't really want to do that. We want to manually
switch the levels. Let's go ahead and
work on that next.
96. 10.06 Preventing Automatic Enemy Spawn: Now to prevent the enemies from automatically spawning or
switching to the next level, let's open up the game mode. Once again, we have to or rewrite this one called
Increment Current Level, because remember we use that in the enemy death whenever
we go to the enemy base. Inside of the death events, we increment the level every
time we kill the enemy. We have to do something about this one now instead of
increment current level, because in this game
you will never, it will never increment
it automatically. Instead I'm actually going
to call it unlock level. We unlock the level and then we manually switch
to the next level. This is done in clicker
games because usually maybe the next level is too
difficult and you have to go a level back to earn
more money to buy stuff, and then you can go
to the latest level. You have unlocked,
this is why it's done. This one is also
called unlock level. Remember this is in
the Player Control where we add the level. Let's actually
change the name of this one to not be confused. Instead of calling
it unlocked level here in the Player controller, let's call it a
level button, UI. This is where we add
the button to the list. Let's call it that instead.
And let's go back to the game mode so we
don't get confused now. It's called this. Okay,
this unlock level. We want to actually
keep running it here. Whenever the enemy is dead, we want to unlock the level. But you only want to unlock the level whenever you
are on the latest level. Whenever I am on this
level and I'm playing, I want to unlock the next level. I don't want to unlock the level if I am playing
level one right now, because I have already
unlocked level two. To prevent this, let's go to the game mode and here
in the unlocked level. Before we do all of
this, what we can do is we can take the
current level. We can ask, is this equal
to the unlocked level? Instead of this
one, we have where it's called previously
unlocked level. We actually need to
change this code. Let me just rename it down here. Instead of previous
unlocked level, I'm going to just call it
Unlocked Level Compile. Make sure that the
unlocked level is one by default because you
already have level one. The current level is also one. We have level one
unlocked by default. If the current level is
equal to the unlocked level, If that is true, we want to go ahead and unlock the next level. Because this means that
if the current level, which is one right now, is equal to the unlocked level, which is one right now, then we are actually playing
on the latest level. And we want to unlock the level whenever we kill this enemy. Let's go ahead and lock that in. Again, we want to increase the current
level if this is true. Now we're asking,
is this less or equal to the max level
If that is true. Now we don't really
want to spawn the enemy because we are only
unlocking the level, We're not switching level. Instead of spawning
the new enemy, I'm actually going to delete. Delete this here as well. This one we can delete as well. And this one as well. We can just go ahead and plug this in. Let me just drag this into so you can
see the whole thing. Now what we're saying is, is the current level equal
to the unlocked level, This just checks that we are actually on the latest level. We have unlocked previously, If that is true and we
have defeated the enemy, go ahead and unlock, or just take this current
level and add one to it. When you do that,
this unlocked level, let's just delete this one, because now we can
just plug this into here, Lock or unlock. But it's going to
add a button for the latest level of
the current level, because we have added one to it, instead of being level
one now now it's level two and it's going to add the button for a level two. Actually, this is sufficient. Now, we are basically just unlocking the level
with this event. And then we are setting
this current level down here to spawn the enemy
here before we continue. This current level
is actually wrong, because we want to set
the unlocked level here. Because it is the
unlocked level that we want to add on, not
the current level. Because again, we don't want to switch the
level automatically. I want to stay in
the current level that I am in right now, but I just want to increase
the unlocked level. Also down here, list this one, and let's paste the
unlocked level. Instead, we're going
to add a button for the unlocked level
that is all correct. Now now to make sure
everything is working here, let's also go to
the enemy base and also make sure that
the code is correct. Now we are at the death event, and here in the
death event we want to unlock the level
that is correct. And remember, the unlocked
level is only going to work if the current level is
equal to the unlocked level. We are making sure
that we are on the latest level, unlocked level, but we also need to make
sure that we want to set the current level because this is spawning our enemies. Let's go back to
the base and let's call the set current level. Let's go ahead and connect it here. Connected here as well. Let us take the current level, and this is the variable here. We're going to set the
level to the current level. Go ahead and compile now, the current level is going to change whenever you
press on the button. If you go to the UI, going to the level code and you
press on this button, it's going to change the
current level value. It's going to change
this set current level. Let's go ahead and try
that. Let's click on Play. I'm going to kill an enemy. Now we can see it's
not switching enemies automatically because
we're basically, if I go back to the code, we are killing the
enemy and then we are spawning the enemy
for the current level. Remember we made this function, we're just taking
the current level which we are not incrementing. We're only incrementing
the unlocked level by one if we are on
the current level. So if I go back and
I keep playing, I can go to the next one. Now I can kill this enemy and going to
unlock the next level. I can go back to level
one or two or three. So I can go back to one, for
example, kill this enemy. And I can keep
getting money from this enemy until I feel like I'm strong enough to
buy some stuff here. And then I can go to the
next level and I can see you can switch
enemies as you like. And it's only going to
add a button if you defeat the latest enemy. All right, so we
are finished here. That is how you prevent
automatic spawning. Just make sure to take a look at if you have maybe
a small mistake, make sure that it is
the current level that is equal to
the unlocked level. And also it is the
unlocked level that you are adding on here, adding, compile,
save everything, and let us move on
to the next one.
97. 10.07 Adding Skull Icons to Bosses: We will make the game a
bit more interesting. I want to add a skull
icon to the buses. Remember inside of
the data table, we selected that some of
the enemies are buses. This one, the Wizard, for
example, and the Rogan knight. What I want to do is add a skull icon to
the level display. Let's go over to the UI, open up the level card, over actually in the
designer. Let's start here. Let's add an image. Let's drag this
image down here to the overlay for this image. Let's change it to a skull icon. Remember we can actually use the one in the
assets objects. The here is sprites. I'm just going to use
the texture or skull. If you just search for a skull and you should
be able to find it here, I'm just going to use the
texture instead of the sprite. Go ahead and edit for the size. Let's try 50 by 50 as well
as for the position of it. I'm going down here
to the transform and editing the
translation for it. For example, for the x
we can say minus six, and that will go this way, and then minus six, and that will go up this way. Zoom, I think it looks good. We can always change
it, but it looks nice. Now this icon here, by default, I want to make it hidden
because I don't want to have it appeared here
for every single button. What I want to do is
here in the visibility, let's set it to hidden
compile now in the graph, let's only add it to
enemies who are buses. Remember inside of
here what we can do is we can always
say get enemy info. We need the enemy's name first. Do we have the enemy's name? We actually, if you
remember in the library, if I go back to libraries
and I put it up, if you say get level info, remember the get
level info structure. If I open up the
level info structure, you have the enemy name
that spawns there. You can actually use
this to your advantage. So you can say get level info. We already have the level here. We can take it and break it up. When we break it up, we
have the enemy name, which we can plug into here. Click on here, Hide
unconnected pins. Then you can drag from here. And break it down as well. From here you now
have the enemy type. Let's drag from here.
Let's say is this equal? And we're not going
to select this one. We're going to select this one because it is an enumeration. This one equal to a boss. Again, click on this one.
Hide unconnected pins we can drag from here
now, and make a branch. If it is true that it is a boss, we want to simply
display this image. Let's take this image. Now we haven't made it into a variable. Let's change the
name of it to image. Skull is variable. Now we can go to the graph. We can take it out and
say set visibility. And set the visibility of it. We can set it to remember,
not hit testable. It doesn't block
the button because visible is going to
block the mouse clicks. So we can't click on the button. Hit testable better.
That should be it. If I compile and
I click on play, now you can see nothing is here. If I buy something here so I can kill the enemy a lot faster, we can switch to the levels, can see everything is
working perfectly. If I switch to level four, and it should appear
here at level five, you can see there is an icon
and it is working perfectly. I'm just going to make the UI slightly larger so
it doesn't buck out. I just minimize this. I go back to the main UI here, Let me just add a level. If I just add a level cat, I can see what I'm
doing like this. Now we can click on the
overlay and we can make it just slightly larger so it
doesn't cut our skull icon. Compile and play.
And here we go. Everything should
work just fine. Go ahead and delete this one
else it is going to bug. As an extra thing.
Before we end, let's actually also add a skull icon beside
the boss name. In the boss name, it is
here in the enemy info. So basically we need
to add one here. Just like before, I'm
going to search for image, we actually need
a horizontal box because we haven't
anything here. I'm just going to search
for a horizontal box first. Add it down here.
Search for the image. Add it as well for the image. Just like before, I'm going
to change it to the score, one size of it is, let's drive 60 by 60. Again, I believe
it was 60 by 60, or maybe it was 50. If I just go back
here, it was 50. Let's just make it 50 by 54. Now let me add this text
into the horizontal box. These two elements
are inside of here. Clicking on the horizontal box, I'm going to make the
anchor to the middle, 0.5 in the alignments to make
sure it is in the middle. And also the position
is zero by zero, so it is perfectly
in the middle. Size to content is true. Basically change the size of the horizontal box to
whatever content it has. Okay, so now we have it
here. Now for the icon. I'm just going to add some padding to the
bottom, maybe two. We push it a bit upwards. Actually, instead of a padding, I actually want to write zero. Actually, I want to
change the translation down here. So you can change it. Instead of adding a padding, you can change the translation. I was going to say minus two, so it's pushed a bit upwards. Okay, just like before, I'm going to make the visibility to hidden and go to the graph here for the
update enemy info. Just like before. Now
we have the enemy name, so I'm just going to
say get enemy info. We have the enemy name already. Then we can break this
up, just like before, we can take the
enemy type and say, is this equal to us? If that is the case, go ahead and show this icon
again, just like before. Let's change the
name to image skull. Let's set it is variable. Let's take the
skull image and set visibility to be hit testable. Once again, click on this one. Hid unconnected pins. Strike this, maybe a bit closer. Let's just try it out
and see what happens. I click play on the game. I buy a couple of these so I can damage a lot quicker
and advance to the levels. Now here is the enemy, and you can see the
icon has appeared. It is working perfectly. But you can see here,
actually I just noticed that this name
is pushed to the side. It's not in the
center of this enemy. This is because the icon of
the skull is actually there. It's just hidden. Instead of setting the skull
to hidden in this case, in this case it was fine
because it's just there. This one is actually
pushing the name. What we can do is set
instead of hidden, you can set it to collapsed. It's like you minimize a menu. It's not in your view anymore. Setting it to collapse
should work just fine. Now if I just switch level quickly just to
display it to you, now this one dies. If I go now you can see skeleton was here before
the text started here. Now is starting in
the correct position. Collapse is a lot better
to use in this case. Okay, cool. So now we have
this skull displayed. Looks cooler than before. And also, I can see that it
is stretching a little bit, the alignment, I'm going to
set it to the middle instead. Go ahead and compile,
save all of it, and let us continue.
98. 10.08 Adding Icons to Shop Cards: The next thing I want
to do here is also add the icons for the cars,
for the shop cats. But because you can see
here, it looks nice. But I think it will look nicer if we have an icon
beside this text. Let's actually go
ahead and add that. Let's open up the
shop over here. Let's add the icon
beside this text. Now it is inside of
a or a vertical box. We need a horizontal
box down here. I just search again
for a horizontal box, and I add it down here,
just above the text. Add the text to the
horizontal box. And then add an image to
the horizontal box as well, just above the text here. Now for this icon, we are going to change
it into the item icon. But for now, just
go ahead and select a random icon for the alignment. Go ahead and set it to
the middle so it's not stretching for the
size of this icon. I think 32 by 32 is fine. I don't think we
need more than this. I probably need a small
spacer between those. Make it look better,
just adding in the x, Maybe four and just like
this. Yeah, it looks nice. Okay, let's go ahead and
click on this image, call it image item. Let's change this
one to Is variable. Now let's go to the graph
and do things with it. Now here in the event graph, let's take a look at where
we can do this best. We have the update item spot I. We have the update, the cost. We also have the
event construct. Whenever this card is added, this would be the best place. Whenever the card is added
From the player controller, we just instantly go ahead
and add the icon as well. Let me just push this away. After updating the text name, I want to take the image icon
and let's say set brush. This is how you set a texture
dynamically or an image. Set brush from texture. Go ahead and select this one. This basically means
set this image from an image I have
imported to this engine. Set brush from texture. Now, which texture do you need? We already have the
icons, I believe, and we actually don't. Let's
go ahead and add that. We only have the
sprite down here. Now to continue, we have to add this thumbnail to the item info. Let's go back, go to the items, actually add item structure info over here. Let's add a new variable
called thumbnail nail. Let's add this one or change
it to a texture two D, which is just a texture
you import or an image. And go ahead and select
object reference. I'm going to move this up just above the thumbnail
or the item name. Remember, now you have to go
to your Google Sheets file. Now over here, I'm
going to go to the item info here to the right. I'm just going to right click up here and insert
column to the right. Call it thumbnail. The same as the variable. Now we can add the
thumbnail over here, references. Now
let's go back to, let's see if we
have them here in the objects actually just
here in the textures, you can just use
those as references, because those are the items. What I want you to do
is open up the table. The first one is
the light feather. Again, just like before the
light right click reference. Go back to your
document. Pasted in. Next one is the
right click here, Reference pasted for the torch. And go ahead and do
that for all of them. This was the final one for me. I'm going to go
ahead and click on File Download as
a CSV file again. Then I'm going to import
this one into again, my data tables
folder. Go ahead and port it, and you should have
all of the information. Now let's go back again and
work and continue the work. Let's open up the shop
item card once again. Now we have this thumbnail. This thumbnail we can
plug it into here. I will click to make a reroute node like this
and click on this one. And hide connected
pins, compile and save. Now everything
should be working. If I click on play, now you can see all of the icons
have been added. Again, I need to make this
panel a bit larger so it doesn't cut out if I just add a card to it so I
can visualize it better. So if I add a shop item
card to the item list, I can click on the vertical box and then I can make
it a bit larger here. So it's not cutting
out like this. The comply now you can see
everything is looking nice. It looks a lot better
if you have an icon beside your shop items. Yeah, that's how you add
them and that should be it. Just go ahead and save.
Just make sure again, click on this icon. Make sure that you have said the visibility to
not hit testable. Do not block anything. Yeah, let's continue
to the next one.
99. 11.01 Adding the Mouse Cursor to the Shop: All right, now it is time to add something with
the mouse cursor. So far we have been
working with the items, But now let's do something
about the mouse cursor. Right now, you click on
the enemy and you do 15 damage per click.
That is good. However, whenever you
progress through the levels, let's say we have
this auto clicker and we progress
through the levels. You notice that the enemies gain a lot more health
than previously. 15. Damage is not really
going to do much to them, especially if we are,
for example at level 20, we have to upgrade
our cursor damage. Let's go ahead and do that.
But first we have to add the click item to the shop so we can buy it
and upgrade the cursor. Let's go ahead and
do that first. By the way, you can try to
do it yourself if you wish. This is really nice practice. Let's try to do it together. If you're not too sure
on how to add one, let's open up the enums. And remember we have all
the items listed up here. Let's add a new enumeration and call this one mouse click. I'm just going to add it as the first item because I
want it to be on the top. This is the mouse click.
Let's close it down. Next we need to go
to the data table. Open up your Google
Sheets once again, inside of here, let's
open up the item info. I want to add it
as the first item. Go ahead and call it mouse
click. Click here as well. Now for the thumbnail I have given you in the
course materials, if you just go back to the assets and the objects
and the textures here, I have given you inside
of the course materials. If you go to objects, this cursor to go ahead
and import this one, right click on it, convert it, or apply paper to the settings. Now for this one right click and make it into a sprite sprite. And drag it into the
objects over here. Now click on the objects. Now we have this sprite set up. Let's go ahead and
save all of it. Let's go back to the data table. Now for the thumbnail, let's go to the textures
right click, copy reference. For this thumbnail edit, the item is called mouse
click for the item. This is the enumeration. Just remember to add
it to the enumeration. We also need a clause for it because we need to
spawn it to the ground. Actually, let's go to
blueprints and do that. Now if I go to Items and
go to the item base, I can right click the item base, Create a child blueprint Claus. Call it mouse click. And let's open it up. Let's click on the
Render Components and add the sole
sprite at the cursor. Compile and save. Remember, we also added the
item names for each item. Here you can see the item name, We wrote that, remember,
for each item. So you have to
write that, else it will not read from
the data table. Remember to click on the
class defaults here. Let's call it mouse click. The same as what you called
it inside of the data table. Now we have this created, and to get a reference to it, just like before, let's just copy this one. Paste it up here. I'm just going to rename this light feather
to mouse click. And this one as
well. Mouse click. Okay. Now for the sprite, again, let's go to the assets objects. We can right click on
this sprite and we can copy the reference
pasted here. Now we have to set
what it costs. Let's just say it costs maybe
ten or something like that. We can always change it later. Now let's click on File, download, download
CSV file once again. Now I'm going to drag it
into the data tables folder. Again, drag it in and go
ahead and save everything. Just make sure that all of the information is correct
here, Everything looks good. Now if I click on Play, I can see my mouse click. And I can see it as well here, I can click on By. Right now it is saying zero
for the cost of this item. Something is wrong here. Remember this is because
here in the item info, we're actually not using
this coins cost anymore. Do not confuse
ourselves anymore. Let's also go to the item info and let's remove the
coins cost from here. Go ahead and save everything now let's make sure that we remove
it from the data table. Right click and delete column, here it is also. Let's go to the items cost now, because this is where
we actually have the cost, Let's change it. Let me just right click here and add a new
column to the right. Call it mouse click here. Basically, Let's say
it starts with 18, just because I want
a different number than all of the other ones, let's say equals this one times 1.2 Let's drag it
down all the way. Now this is obviously
going to need a lot of work in game design if you want all of these
numbers to make sense, but for now we're just testing. I'm just going to
download this items cost data table
here in the engine. Let's go ahead and
import it once again. Go to data tables, import the items cost. Now cannot find the mouse
click property in ST cost. Let's actually take a
look at this together. If I click okay and I
just go to the STM cost. If I go to the UI, I actually to the structure, open up the item cost. This is because we are missing this variable inside of
here. Let me add a new one. Call it mouse click, make it into an integer. Just drag it all
the way up here. And go ahead and click Save All. Now for this item cost as well. Remember in the player,
if I go to the player, we have a function
called yet it cost. If I click on it, we have
to link these together, else it will not work
just like before. Go ahead and link them together. Compile if you want
to make sure that you have not missed
any other places. Also, right click
on this item Cost, Go ahead and click on Find
References, just to make sure. And click on the small icon, and this will show you all the references
you have used for it. Clicking on this one, we haven't really done
anything here. Everything should
work just fine. Now let's go back to the data tables and I'm
going to re import it, so it is correct like this. Now it is fine. Now
let's click on play. Now, my engine crashed and it usually does that
sometimes when you edit things inside
of a structure and you try to click
on play, it crashes. But when you open up the
second time, it should work. Now if I click Play and you sometimes can see
things like this, you can actually fix this. Sometimes it needs to refresh. If you open up the play
control and you click on file, refresh all nodes, and you click on play again,
it should work. I don't know why it does
that sometimes it usually does that for my
other games as well. But you can go out and refresh
and it works just fine. Okay, now you can see the
mouse click is working fine. And if I buy more and more, it is working fine as well. It's showing me the price. Now we need to add a span
point for this mouse click. And let's do that
in the next lesson.
100. 11.02 Adding the Mouse Cursor Spawn Point: To add the mouse.
So spawn point, let's go ahead and do that here. Let's open up the spawn points. Now we have this
item spawn points, so we don't really need
to create children, remember we only use this one. We can click on the first one and make sure it is mouse click. It is by default because we have rearranged the
enumeration previously. Clicking on this
one mouse click, now open up your enumeration
and just make sure that all of these are
correct in order. I believe that one of them is wrong because we
still have ten and we have the mouse
click as one of them, one of these items are missing. Just make sure to
click through all of them and make sure
that it is correct. I'm just going to actually
copy this one up here. Let me make sure that it is the same distance as all of the other ones and
it is like this. I make sure that this
one is mouse click. The next one is light feather. And just go through them here. The next one is Torch and so on. Okay, now they are in
the correct order. Go ahead and save all
of them when they are. Now if you click on play
and try to spawn it, it's not going to spawn. Remember we set some that we need to take care of. If you open up the game mode and you remember what you did
with the items points, we created this function
here called set items pon points and get items points. Let's open up this one,
Set items pinpoints. We need to make one
for the mouse clicks. I'm going to duplicate this one. I'm going to call it
mouse click points. Go ahead and add it to up here. Let's make sure we don't
have anything else. Let's compile. Let's go to the Get items, pin
points as well. Let me just copy
paste this here. Delete this one and add the mouse clicks instead.
Go ahead and connect. Compile. I believe
this should be it. Click on this one, you can
see it is working correctly, just like the other items. Now this is working just fine. Now, there is a problem
right now with this, because it should
not show zero DPS, and also it should not show
currently doing zero DPS. The problem with
this one, right now, the mouse is not really
damage per second, the mouse is damage per click. Instead of showing
damage per second, we need to show
damage per click. Right now it is saying zero
DPS because in the item info, we haven't specified how much damage per
second it should have. For example, you could say five. And if I click on Play, you can see it says five. But again, we're not really interested in damage per second, we're more interested
in damage per click. So let's go ahead and fix
this as the next thing.
101. 11.03 Displaying the Damage Text Correctly: To make the text
displayed correctly? Obviously, we have to go
to the UI now and take a look at the tooltip.
Let's get in here. Let's open up for the DPS now just to make sure that the text is displayed correctly. Now for the damage,
I'm just going to write something like
40 to make sure that this I'm looking at
is the fake or static. I. I'm making sure
when I click on play, I'm actually looking
at the real thing here just to make sure
that I don't have an era. Now, here in the graph, we need to make sure that
it says for the mouse, it say each mouse click gives five damage per click. And currently
doing, for example, five damage per click
instead of DPS. The first text, remember
what they are called. The first one is
called, gives DPS and the second one
is gives DPS amount. Now this one we don't
really need to change, we only need to this gives DPS amount and doing DPS
amount, let's go back. This one gives DPS amount. Instead of saying this one, I'm going to disconnect it. I'm going to direct from
here and say Select. Now we need to use
a select node. Now what are we
going to select for? We're going to select for if this is a mouse click or not. Remember we have
the item info here. And if I just hide this thumbnail because
we don't need it. But I show this item we can
drag from here and say equal, equal enum if this is equal to mouse click and plug
it into down here. Now what we can say is, remember we need to
use a format text. Again, I'm going to drag
here and say format text. I'm also going to use one
down here, format text. Now for this one, if it
is not a mouse click, it should just say the same
thing as it said before. Go ahead and paste it in Enter to see this. Now this is the DPS
amount, just like before. I'm actually going to
drag this back into here, and I'm actually just
going to push this away so I have some
space like this. Now for this one, if it is true that this is
the mouse click, what I want to say here
is instead of DPS, let's just say damage amounts. Let's say damage per click. Now I'm going to say
damage per click. Basically, the damage per is this DPS here. This DPS, we can
choose to set it to how much damage it should do or give you whenever
you buy from the shop. If I just compile
and I go back to my data table just to
make sure it is correct, open up the actually not item
cost item info for this. I'm just going to
say that it gives me 25 damage each time I upgrade. And also make sure
that you go to your Google Sheets
and change it here, else it's going to be wrong. Every time you
import this table, make sure that it is,
for example, 25 here. Now inside of here,
let's go back to the Tooltip and let us continue. This should be correct.
I can delete this one and I can push everything to the side so I can have
these in the view. All right. I just
rearrange things nicely. Now this is correct.
Now let's continue. The next thing is this
one text doing DPS. This one before you can drag
from here and say Select. Then just before format
for the first one, format text, format sex
for the second one. Again, it should choose if it
is the mouse click or not. I'm just going to drag this
into here just like before. If it is not the mouse click, let's actually just add this one that we had before.
We don't change it now. However, if it
is the mouse click, what we want to say is total
amount of damage here. For example, this one is
total amount of damage. This one is basically going
to say it's currently doing, for example, 60 damage. You can also call it damage per click if you want
to stay consistent. Let's call it damage per click. Now for the damage,
it's not really this DPS that we add here, but it is more correct to add
the cursor damage variable. Remember inside of the player, if I go back, this
is a long time ago. Actually from the
beginning of the course, we created this cursor
damage float here, we can actually add this one. I go back to the tool tip, we already have the
player if I can drag from the player and say
cursor damage. Now we can add this into here and it should
work just fine. Again, I'm going to delete
this one for this number. Again, plug it in here
so it is not wrong. This was what we had before. I'm just going to
rearrange things nicely. All right, just like this and go ahead and compile
and save all of it. Let's click on Play and see what happens if I hold
a mouse over it. It says each mouse click
gives 25 damage per click. You can also call it DPC, I believe is a term
actually, instead of DPS, you can call DPC for damage
per click if you buy more. You can see that it is not really saying
anything and this is because we're not updating it like all the other
ones we're doing. This is actually the next
thing we have to do. We need to update
the currently doing, because it is actually giving
you 25 damage per click. But you cannot see
it because you're not updating the
text beneath it. You're not updating this
cursor damage variable. Let's go ahead to the
next lesson and do that.
102. 11.04 Upgrading the Mouse Cursor Damage: It's now time to upgrade the mouse when you
click on play and buy. The mouse clicks
here you can see that it's doing
automatic damage, which is not supposed to
happen because the mouse click is basically
where you click on the enemy and it
should do more damage. Let us go ahead and upgrade the mouse damage instead
of the automatic DPS. Let's close this down. And we did that
inside of the player. If you open up the player and we go back to
the event graph, if you wish to say organize, you can always right
click up here and close tabs to the right so we don't have to
see all of these. When we purchased the
M, remember what we did previously is that we
updated the total DPS, which was this function
inside of here. Instead of updating
the total DPS when we purchase a mouse click, let's actually do it here. We want to upgrade
the mouse instead. Here's the right
in the functions, we can click on the plus. Let's make a new function
called increase cursor damage. The only thing it's going
to do here in the input, I'm going to add a float and
call this one damage to add. Let's take the cursor damage we created earlier. Let's add plus the damage we want to add. Then let's set it back
into this variable. So now we have this
new cursor damage. This is basically what the function is of
this function here, is that it just adds the
amount of damage we want to add to the cursor damage and
sets it here as a new value. Let's go back to the
event graph and let's use this one increase
cursor damage instead of the total DPS for the mouse. Now to know if it is the mouse we are
talking about or not, remember here in
the item structure, we can click on the item info and we can hide
everything for now. Over here in the item, remember in the enumeration we made the mouse
click enumeration, I'm going to do, click here and I'm going
to drag from here. And then I'm going to say
equal, equal enumeration. And then go ahead and select
this mouse click here. If this enumeration is
equal to mouse click, if this item we're talking
about is equal to mouse click. The way we know that
inside of the data table, this is where you set
your information. If you open up the item info and you open up the mouse click, remember we set the item as
a mouse click over here, so it's going to know
what you have chosen. If you have selected
something wrong here, you will get an
error if the item here is mouse click and we can drag from here and
then we can make a branch. Now I'm going to add it.
After I spawn the item, I'm actually going to
disconnect this one. And let's drag those here. Now, before we update the UI, because we need to do this
before we update the UI, the UI updates correctly. We need to add the information, we're going to spawn the item, and then we are going
to connect this branch. Okay, this is the mouse click. If the item is the mouse click, we want to increase
the crystal damage. If it is not, we want to
update the total DPS. Then remember to connect
them back to here. If you want to stay a
bit more organized, you can always double click this one at a rear
route node like this. And you can take this and plug it into here,
so it looks better. Now we want to add the
damage we want to add here. Let's just take the DPS. If I click over here, I click on the DPS and I can drag this all the way
to the function like this. Again, I'm going to create
some rear route nodes for it. And just like this, Okay, now we have the DDPS blocked in. Now, every time we're going
to upgrade the mouse click, we're going to add it into the increased cursor damage
instead of the total DPS. Now if I compile and click on play and
I upgrade here, you can now see my UI is
or updating correctly. If I click on the enemy, it is also doing the
correct amount of damage. If I click on him, it says 65. If I upgrade again, it says 90. I upgrade again a
couple of times. It says 240, and it
should say now 340. And you see it is doing the
correct amount of damage. Now we are finished with
upgrading the cursor.
103. 11.05 Designing the Mouse Cursor Widget: To make it a bit
more interesting, let's go ahead and change
the mouse cursor because you can see we have the normal
windows mouse cursor. But let's change it
into another icon, so it looks a bit
better to do that. I have given you here
in the cost materials, I've given you
some mouse cursors that I actually
used in Farm Tail, but we can use them now. Here, let's go to the
UI and to the icons. Let's just drag these
icons into here. Now you don't need
to apply paper to these settings because it
is not the pixel lots. Let's go back to the UI. And let's right click here, make a new user
interface widgets. Go ahead and click
here. Let's call this one mouse cursor. Let's open it up inside of here. What I want to do
first, I want to add a canvas panel. Let's
drag that down. The only thing we want
to add is an image. And this will be the cursor. What I'm going to do again, I'm going to click up
here and say desired on screen for this image. We can give it a size. Now for the size of the image, it depends on the
mouse cursor size. If I go to icons and I take
a look at this mouse cursor, it is 93 times 101. So let us write that, 93,100.1 As you can see, the image size is not changing. This is because you have to
click on Size To Content, and now it will be correct. Okay, this is correct. Now what we want
to do is we want to center it as
well to the screen. And not being up here, I'm going to change the
anchor to the middle. And I'm going to write
00 here in the x and y. And we don't want to write
0.5 in the alignments because the mouse is actually
going to click in the middle of this canvas. This is correct so far.
Clicking on this widget, let's change it to the cursor. And this is the default one. The mouse cursor here. And let us compile and save. I believe we have to make it smaller because it will be
very large in the game. But we have to test it
first before we know. Also for this image, I want to set it to
not hit testable, so it doesn't affect the game. Now it is ready to be used. Let's go back to the
player controller. Inside of the player controller, just like what we have been working with the UI previously, we want to work with this one up here in the
initialized player. Now we're not going to open
and close a widget here. It doesn't make sense
to credit here. Instead, we're going to add
it to the initial player. I'm just going to
copy this widgets. And let's search for our mouse cursor. Let's
strike click here. Promote this to a variable
and call it mouse cursor. Now if you drag from here, and you just search
for mouse and see something called Set
mouse cursor widget. This is a default function
inside of Unreal Engine. If you click on it, what you want to do here is
basically select Default. This will be our default cursor. We have now defined
that this widget we just created is now
the default cursor. If you click on play, now you
can see this is the mouse. We can use it to click, and you can see it
is very precise. Now I'm going to push
it a bit upwards, because as you can see, it's
clicking a bit upwards. If we go back to the widget, now I think I'll make it a bit smaller because maybe
it's too large. Let's go back and fix this. Let's go back to the
UI, open up the cursor. You can always click on
here and say for example, minus five here,
minus five in here. Minus five inter as well. I think I'll say minus five
again here, minus five. If I click on play
and take a look, I think it can be a bit smaller. Again, minus ten,
maybe minus ten here. Click on play. I think
this is a lot better now. Now if you want to
push it upwards, you can always adjust the
position in the X and Y. If you write five, actually it's minus five to go
to the other way. Let's say a minus
five by minus five. That is a lot better. You can again, try to
adjust this as best as possible here when
you are satisfied. Now this is the mouse we have. Now we also need a click event, because as you can see
when we are clicking, it's not really giving
another effect. And I think we can
make it a bit better by having a click effect. This is the other cursor
we have imported. This is the pressed, Okay, so if we go back here now, I set this position x to minus eight and minus five
to make it a bit better. Now when you are ready, let's go to the
graph and interfe. Let's delete all of this. I want to make a new custom event. Let's make a new custom
event and let's call this one set image. What we want to do here, I actually want a new enumeration. If you go to the blueprint
and open up enums, let's right click and
make a new enumeration. This is basically
going to contain a list of the pressed
mouse states. If I just call its state, I open it up, actually I'll
give it an S here at the end. Now here for the
mouse cursor states, we could have a
default mouse cursor, We could have a
press mouse cursor. Now we have these two states. If I go back now to the widget and I add
this as an input, let's search for mouses and select this enumeration
we just created. I'm going to call it Moussa
states the goal here. What we're trying to
do is we're trying to change this image depending
on if we have pressed or not. I'm just going to call
this image mouse cursor. Let's set it to variable so
we can change it in code. If I go back here,
I drag this and say set brush from texture. Now the texture
depends on what we have as a mouse cursor state. If I just drag from
here and say select, and I select this node here, and we can drag this
into the index. Now if it is the default state, this is what we have written
inside of the enumeration. If it is the default state, I want to select
this mouse cursor. If it is the pressed state, I want to select this
mouse cursor here. Now we can use this set image, depending on what we're
doing in the game. Remember pressing buttons. We did that inside
of the player. If I go back to the player, I go to the event
graph, that is correct. Now we need to find
the event that we used whenever we
click on the enemy. Now we haven't really
made one because so far what we have been doing
is inside of the enemy, we have this click event here. This up here on clicked
on the capsule component. We haven't really
made an event here. Whenever we click
with our mouse, we actually have to
do that as well. In order to do that, we
have to work with inputs. Let's do that in
the next lesson.
104. 11.06 Adding the Mouse Click Input: All right, to finish it up, we have to add a mouse input for whenever we click with the mouse so we can
change the image. To do that we have to add
an input for the player. If I just write, click here
and make a new folder, and I'm just going
to call it Player. And drag this into here. Inside of this Player,
I'm going to write click and make a new folder
again, call it Input. And let's go inside
of this folder, right click inside
of input here. If you haven't worked
with it before, this is where you add the
keyboard keys and so on. So whenever you walk in
an RPG game and so on. So basically just the input for the keyboard
and mouse and pads. Let's first create an
input mapping context. This is what you have to
do. Let's call this IMC. For input mapping context, you can just call it default. Okay. Right click again. Input, and we have to create something called
an input action. Go ahead and create
one. Let's call this one mouse
click, for example, mouse click. Let's
open this one up. Now, inside of
here, what we need to do is basically nothing. Let's close it down,
because we just need to click on the mouse and
something should happen, so we don't really need
to do anything here. Let's open up the
input mapping context. Inside of here, we have
to click on the plus. Now when you click on the plus, you have to add an input action. This is what we just created
called a mouse click. For this input action, you
have to assign a button. Now for this one, I'm
just going to click here. And then click my
left mouse button. And it will assign
it automatically. Also find it up here if you
just search for mouse and you can see you can select
all of these things here, but we already have it
here. Left mouse button. I'm going to click
here in the triggers, I'm going to click on Plus and select the one
called pressed. The reason I do this
is if you don't do it, you're going to click
multiple times. I'm actually going to show you if I just delete this for now, We can just leave it and
we can come back to it. Now we have to add
this to the player. If I go back to the player, I open up the player, we have to add the input
mapping context into here. Before it works, let's do
that before we update the amount of icons and
damage and so on. So let's do it inside of here. What we can do is we need
the player controller. I'm actually going to take
this player controller, you can search for enhanced, you see this one called Enhanced Input Local
Player subsystem. Go ahead and select this before we go ahead
and work with it. Always direct from
here and say is valid because it will
give you an error sometimes where it has not
been loaded and you're trying to move the player or try to do some input actions. Go ahead and select
is valid first. Whenever it is valid, we can drag from here
and say input this one. Add mapping context,
Go ahead and select. And then for the
mapping context, select the one you just created. Now it should work just fine to test if this is
actually working or not. You can just go here
and write click and search for the input
action name you created. I created the one called a mouse click. Go
ahead and select it. I'm just going to print
a string to the screen. Compile. If I click here, you can see it says hello. If I click with the
mouse, it says hello. The reason why we
need to add a trigger pressed for the input action
is because you can see if I hold the mouse
down going to spam this code that I
write inside of here. And this is not what we want. If I go back to the input mapping context
and the triggers, I click on the plus and I
add this pressed state. What press means is
it's only going to play the code once
whenever I click here. And this code is going
to play if I just write a print string again
and I click on play. Now if I hold my mouse down, you can see it's
not going to spam. It's only going to say it once. Every time I click, I'm going
to click multiple times. Now you can see it's only going
to print a low whenever I click on the mouse and it's
going to print it just once. This is just for optimization,
so you don't play the over and over again. Now we can actually use
this input action. Let me just move all of this up. Let me add this one down here. Now we can use it to
show our mouse cursor. Remember the mouse cursor is inside of the
play controller. Again, let's take
the play controller. Let's track from here, let's search for the
widget we created. If you search for mouse
and go to the bottom, this is always where
your variables are. We created this one B mouse
cursor inside of here. If you don't remember, we
just go back to recall. Go to the graph we created. This one called set
mouse cursor image. If I go to the player, I drag and say set
mouse per image. Whenever it is triggered, we're going to set
the P to be pressed. Now, instead of just doing this, we have to do two things. Whenever it is completed and
whenever it is triggered. Whenever it is triggered, we're
going to set it to press, and let's copy
this and paste it. And drag this into the target
whenever it is completed. Let's do the default one, let's actually see what happens. F p, you can see it's
actually working, but it is triggering
very quickly. This is because it's
triggering this here. But whenever it
goes to complete, which happens
almost immediately, it's going to set it
to default again. This is actually
what's happening. This is why it's
looking like this. Now to fix this,
let's go back to the input mapping
context inside of here. Let's add again another one. Let's just add the same thing. The left mouse
button, click here. Click on the left mouse
button on your keyboard, or on the mouse in the triggers. Click on the now, instead of only pressed up here. We also have to select Released. Go ahead and do that. Save.
Let's go back to the player. Actually, you don't
have to do anything. It is correct If
I click on play, now you can see if
I click, I release. This is now correct. This is Do the mouse. Now you can see
it has a cooler effect with the mouse when we have changed the cursor to this one
instead of the default one. And we have the pressed
states as well. Now in the future,
if you want to add more mouse widget states, again, you have to go inside
of the enumeration, the blueprints, Add the
states inside of here. Then remember to go to the UI, open up the mouse cursor, and also in the graph, remember to select
the correct images that you want to use here.
105. 12.01 Designing the Final Map: All right, so now it is
time to design the map. So I click on Play. Everything is looking good. We have the level,
we have the shop, we have the coins, we
have the mouse cursor. But now let's actually also
design the level itself. Now I'm going to do
it on my own time, but just to remind you, we have to go to the assets and to the environments inside of here we have this
tile map gem prison that we created earlier. Remember, you can switch between the tile sets up here.
You have the props. If you wish to add some props, for example this one,
you can click on it. Or you can click and drag
here and select both of them. You can add them
here. Remember to work with the front layer, base layer, and decorations. You can always create more
layers if you wish to, because if you just paint
on the base layer here, it will delete your tiles. So you have to
create a new layer and then add it so you
can add it to the front. If you want this to the back, you can always click this arrow. Now it is beneath the
tiles so you can't see it. I'm going to delete
this one for now. What I'm going to
do now is basically just increase the map size, which is the map
width and height. For example, you can
write something something like 50 by 50 or
whatever you wish to. Maybe that is too large, but try to find the map
width that is for you. The thing is here
is we're trying to avoid all of this black
space to the side, just make it fit more. You just have to
guess, for example. You can just make a larger map and try to add
something like this. And if you click on Play, you can always see
where it reaches and then you know
where to stop here. But basically I'm going to make this map larger just
to avoid the black space. We don't really need
to do anything else. Basically just increase the map, try to work with the layers. Go ahead and select the tile. Try to paint the
map as you wish. Now, keeping in mind
that you have all of these spawn points
for these items, you can always, for example, just an idea, create rooms for these items or create a
hole for these items. Basically making
these items fit into the game as well as this enemy spawning
maybe in the middle. It is the center
attention for this game. Just design it as
best as you can. There's not really
any rules here. I'm just going to design
it as best as I can. Just try to play
with all of these. Maybe try to play
with the corner. See how they work together. For example, this with this one, like this and this
one here. Basically. Just try as best as you can to design the map and
I'll be back with you. All right, now I am back. I have spent around 30 minutes
trying to design this map. As you can see, I have
designed the map. And here it is. I just designed the map inside
of the tile map. The map width and height is 50. I just added some random tiles. Just designing the
map however you want. It doesn't really matter
how you design it, It's not really going to
affect anything this course. Just try to be as
creative as possible and have fun with it once
you're finished. And you can see here,
I've also moved the item spawn points to
be on the ground here. Whenever I buy
something it's actually going to spawn inside
of this thing here. Now I can increase
the row amount of items it can spawn here. Maybe I want to increase it. Let's try to do that.
Let's go to the blueprint. And we did that inside
of the game mode. If I open up the game mode, and let's see here we have this set items
points function. Inside of this function, we
had some local variables. Here, the local amount
of rows is two. I wanted to stay two. Now we can have the
local loop last index. This is the amount of
items. This is ten items. Because it goes, remember
0-9 it's ten items, I, let's try to add three to it. I'm going to buy some items. Here it looks like. And now it's fitting to the map. This is what I'm
going to go with. This is my map currently. Also, I want to increase the timer slightly
because I think it's too small and it's a big focus in the game. Let's
close this down. Let's go to the UI. Open up. Let's see here,
the main UI here. Let's click on the text. Instead of 28, let's maybe write 36 as well as for the icon, we have to increase
it, maybe 60 by 60. Instead, let's click on play. I think that is a lot better because it is still
the main focus. We can even increase it
further, maybe like 40, and this one is 60, 64 by 64. For example, clicking on play, this is what
it looks like. I think this is a lot
better because it's, again, the main
focus in the game. Everything looks nice. Now, if you want to change
anything in the game here, basically, you can always go
in here and adjust things. But I like it like
it is right now. I like everything about it. You can even increase the
name and health if you wish. I'm actually going
to do that slightly, just so we can see it better. Clicking on here, instead of 28, I'm going to write
32 for the call. I'm going to write 55, 55 also for the health. Going to click on the
health 32 instead. Compile the com Play. And now you can see it is a lot larger and it's again
the focus of the game. So it's always nice to
have that UI to be larger. Okay, now let us continue
to the next one.
106. 12.02 Preparing the Sound Cues: All right, so now we are
at a stage where we can add some sound effects to
the game, and also music. And it will make the
game a lot better. Sound effects add almost half of the experience of the game. You can see, even though
we made a fun game, it's still boring
without any sounds. And yeah, let's add some sound effects and
make it more interesting. Now in the content folder,
I'm going to write, click, and make a new
folder called Audio. And inside of here,
let's go in here. In the cost materials, I have included all of
these sound effects for you in the cost materials. Go ahead and open
up the SFX folder. All of these, go
ahead and select them and drag them into
the audio folder. When you drag them in,
you see all of this, and by the way, a lot of
them are really loud. Don't click on play right now, else your ear drums might blow. You can always lower
your sound for this, but they are super
high in the volume. What we want to do is we want to create something called
sound cues from these. Let's start with, for example, this one called purchase. Let's write, click and create Q so you can
create it up here. What I usually call it is I
delete this Q in the end. And I call it S C for sound que. It's called sound que purchase. Now I'm going to double
click on this sound que. And inside of here, very simple, we can just lower
the sound of it. I'm going to write
0.2 and then I'm going to click on Play and
see if it is loud or notes. This is the sound of
it. I can maybe make it 20.4 something like this. We can always adjust
the sound later, but that's what I
want you to do. For example, let's
take another example, this one called FX
punch, right click. And I create a que of it again. Let's call it Sound Punch, open it up lower. The sound maybe 0.4 Still
super loud. Maybe even lower. Because this is going to
be spammed in the game, maybe 0.1 or 0.05 I don't
know, we will figure it out. Now a method here for
the punch you can, it's sounding the same if
you're clicking on the enemy. It's getting a bit annoying like when you hear the same
sound again and again. To change it up, you can
always strike from here. You can see there
are not many things you can do inside of here, like in the blueprint
graphs we usually see. But what I want you to use is this one called a modulator. Go ahead and select it and
connect it here instead. Now what a modulator is doing, it's going to change
the pitch of the sound. If you click on it and
change the pitch minimum to 0.9 and the maximum to
1.1 Save all of it. Now if you click on
Play multiple times, you can hear that the sound changes every time
you click on play. It's not completely
the same sound. It's trying to regulate or change the minimum
and maximum pitch. That is done for this one. Now if we have multiple sounds, for example, I have this one
called or Death 01020304. All of these go together. If I just select all of them, right click, create a single. When we create that, I'm
just going to rename it to Sound Or Death. Go ahead and go inside of it. And now you can see it
already made this for you. It created a random node. It plugged all of
these sounds into it. It's actually going
to choose the sound by random when you
click on play. Now, before I do this, also
reduce the sound and click on play super loud. Maybe 0.10 0.15 Maybe
0.2 is actually good. 0.2 is fine. Sounds nice. Now all of this is good. Let's just close
it down for now. The Ascension
again, right click. Make a create A and delete this. Call it S C, Ascension. Open it up, reduce
the volume to 0.2 for example, close it down. Then let's take the next
one, the button hover. Let's right click create
a Q for this one. Again, let's call it a
button over and let us reduce the sound
20.2 Close it down. Let's go to the next one, which is the button
pressed right click, create a que sound like this. You can see it's the
same method again and again just to
reduce the sound. Now pressing a button, I actually want to add
a modulator as well. Modulator for this one as well. And connect it, pitch
minimum and maximum. Let's set it 20.9 to 1.1 then. Now it sounds different every
time we press the button, which is really nice. Now we have the Night
Death again. Right click. Create a sound
que. It's a bit of a boring lesson because we're basically just
doing the same thing. But I just want to show
you how you create them. Just so I know you
have the concept, let's just make a
0.2 Sounds fine. The next one we have
is the level unlocked, right click. Create a que. Let's rename it to open up
this level unlocked bus. Reduce the sound to
0.2 Close it down. Now the next one is the
unlocked normal right click. Create a que, call it
Sound que like this, and open it up again, reduce the sound to 0.2 You can see the same
method again and again. Now for the music. Let's
right click here again, create a sound que, let's call it Sound Music Now
for the music. Let's open it up, and
let's click here. Let's make sure that
we have ticked. This is looping because you
need to loop the music, else it's not going to loop and it will stop at some point. Now the C we have done already. Here's the or death.
We have done already. The punch as well, the purchase. We have done the death
for the rockets. Right click que. We're almost finished. It has been a boring lesson. Let's call it Sound Q
Rogue 0.2 We'll sit down. The skeleton. Now let's
select the skeleton. Right click, Create
a single que. Again, let's change it to 0.2 And I should remember also to change
the name for this one. The final one is the wizard. Death right click Create. Let's call it Sound
que, open it up. 0.2 Now I'm going
to, on my own time, adjust all of these volumes because it's basically
just click on play here. And then listening to
how loud the sounds are, just adjusting the volumes
of them when you are done. Let's go over to
the next lesson.
107. 12.03 Adding SFX to the UI: All right, so now that you are finished with creating
all of the sound cues, let's go back to the UI. Now I want you to
take them one by one. The first one I can
see the enemy info. We don't really have
sound effects for those, it's just some text
and some health parts. The first one is the level card. Whenever we click on
this level button, let's click on the button.
Let's go down here. And you see something called
pressed Sound and hover. Sound Let's go ahead
and change this. Now if you click on it, you can see all of the sound cues and the sound that you have
imported inside of this engine. Now this one is the pressed, if we just search for press
and we select this one here, we search for hover
and select this one. Compile. Now if you click
on play and you try it out, you can see this is the
hover, this is the press. It's a bit more interesting
that they have sounds here. Let's close it down.
Let's go to the next one. Let me just delete
this shop card just to see or
test this UI here. We don't really
have anything that makes sound here.
Let's close it down. Let's open up the shop item, Cod, Inside of here we
have this button again. Let's go down search, pressed actually for this one. Let's search for the hover Sound that is fixed. Let's
close it down. The last one is the tool tip that doesn't contain
anything either. Let's go ahead and
save everything now. Before we finish, let's
also add the mouse click. The best way to do
this is if we open up the enemies and open
up the enemy base. Remember inside of
here we did the click. We also have all of
this applied damage. Spawn float effect,
and hit effect. Let's actually do it here. If you drag from here, if you just search for sound, you have something
called Play Sound two D. You also have
something I just search for, Play Sound have something
called Play Sound two D, and play Sound at location. Play Sound at location is
usually used normally. For example, in three D games
where there is an enemy far away and you can hear the sound far away at
a certain location. However, this is a
two D game and we basically have the sound as a two D. Let's play the sound as two D. This is mostly
used for UI elements. You can also hover
over it and it says a sound directly
with no attenuation, which basically means
you cannot hear it like coming from a distance
or from a location. It is perfect for UI sounds. Let's select this
one for the sound. You can go ahead and
select the punch. And go ahead and select
it now you can do it like this or you can also
just right here, promote this to a variable
and you can call it, for example, punch sound effect. This is always good because instead of later
on in your game, instead of searching for it and you don't
remember who it was, you can always
just click on here and change the sound
effect from here. Now we have the
punch sound effect if I click on play
now and try it out. Now the other thing we can do is whenever you unlock a level, let's go ahead and make a sound. I think that will be a
lot more interesting as well for unlocking the levels. Remember, you did that
inside of the game mode. In the game mode,
if I go back to the vent graph and we take
a look at the unlock level, Let's actually
play it from here. Let's go ahead and do that here. Let's drag from here. And again, play Sound Two D, I actually included two
different sounds for you. If you go back to the
audio and you open up, you can see here you
have something called unlocks and unlocked normal. Depending on if the enemy is
a boss or a normal enemy, we can actually do
something with it. Now the way we do this is again, we can drag from
here and say select, because now we can
select the sound, depending on the value, to get the next enemy's status. For example, if it's a
boss or a normal enemy. Remember we can say
get enemy info. Go ahead and select
get enemy info. Go ahead and break it. Break up the structure
from here we know the, the enemy type here. Let's go ahead and plug this in. Depending on if it's
a normal or a boss, we can go ahead and select, actually let's right click here, promote this variable instead. Let's call it level unlocked FX. This one is the normal. Let's right click on this one
and promote this variable. Let's call this one
boss at the end. Okay, now we have these two selected and unconnected pins. Now for the enemy name,
where do we get this? Remember, we can always
right click and say get level info. Go ahead
and select it. Now for the level we want to get it from is the
unlocked level. Go ahead and plug this in, because the unlocked
level is always a step ahead of the current level. Let's break this up again. And now we have the name
which you can plug in, hide the unconnected pins. Go ahead and just make it
more structured like this. Now we have this information. It is only going to play once because whenever we
unlock the level, it's going to play
the sound once. Let us compile and
save all of this. Now you can a go
ahead and try it out. But before we do this, let's add the sound for
the normal one, we can search for unlocked, unlocked, and search
for the normal one. For the next one, for the boss. Let's go ahead and select
the unlocked boss, compile play, and
let's try it out. This is the sound when
you unlock a level. If I do that again, you can see there's no sound because I'm
still playing level one. If I go back to level two, go over to level two,
now I have the sound. Awesome. Now this
is the last one. When I kill this
one, it should play the boss sound effect
or boss unlocked level. Let's try to do that.
Now it is a boss. You can see it is a lot more
interesting to play with. Now, before we continue to giving the enemy
some sound effects, let's go ahead and give the purchase a sound
effect as well. For the purchase we have
here in the player. Remember again we have
the purchase item. Let's go ahead and
add the sound effect here before we do anything else. Again, right click Play. Sound two D, Go ahead
and add it here. Let me just right
click on this one and say Purchase Sound Effects. And drag it down like this. Now for this one,
let's click on it Compiled first and
search for purchase. And that should work, just nice if I click Play and
purchase something. Now I see that sound is playing. I'm just going to go
ahead in the audio and just turn it down a little
bit. I think it's too loud. If I open it up, write 0.4
instead and play again, I can see it is working as well. Okay, now we have all of these
sound effects implemented. Let's save everything now. Let's add some sound
effects for the enemy.
108. 12.04 Adding SFX to the Enemy: Okay, basically every enemy can have a unique sound effect. To do this, remember we
created a structure. If I open up the structure
and open up the enemy info, what we can do is we can
add the sound to it. Because remember, every time
you add a variable here, it will be unique to that enemy. For example, if we
click on Add Here, and we can say effects,
death, sound effect. And if we just search for sound, go ahead and select this Sound. So what you can do is you
can go to Google Sheets. Inside of your Google Sheets, go ahead and open up the enemy info over here to the right. Go ahead and write the death
as effects you just made. Now what you can do is you can add references just before. We can always go
to the audio now. Now for the first
one, let's see here, it's all of the four first ones are the, let's go over here. We have the C one. Just
find it down here it is, over here, the
death right click. And then copy reference
just like before. Go ahead and add it now. Technically you can have
a Orc death sound effect which is unique to
every single one. But I'm going to just
use the same one here. Because I've added here, remember in the sound cue, we added a random
one from these, it's just going to pick
a random death sound. But basically you can assign a unique death sound
to each single enemy. Now for the wizard, I'm
going again to go down here, Find the wizard
Death, right click, copy, reference, paste it here. The next one is the skeleton. Let's find the skeleton
which is here. I'm going to rename it and
remove this, 01, right click, copy reference, and paste
it on The next four ones, this, this, and this. Now we have the rogue
death and night death. Let's search for the
rogue. The night is here. Copy reference past for
night for the rogue. Let us right click Copy
Reference Basis for the rogue. Again, click on file, download it as a CSV file. Now go ahead and take this
enemy info to the data tables. And basically just drag it in and it should have
all of the information. Now go ahead and save. Now whenever the enemy dies, and this happens inside
of the enemy base, Let's open up the enemy base,
save everything, compile. And let's see here
where we can add it, so we're doing any damage. Over here at the end we have the death F double click on it. And it is down here
whenever the enemy dice. Let's actually do it here. Whenever we play the flip book. Let me just play the sound
before I play the flip book. Now I don't really
think it matters whether you play one
thing first or the other, but I'm just going
to do it that way. Let us again play Sound Two D. Go ahead and
connect it like this. And go ahead and connect
this effects to here. Now it's going to select
this sound effect, depending on what
you have given it as information in
the data table. So go ahead and compile. Click on Play, and
let's try it out. Okay, that works nice. All right, so now we have the problem of the sound
playing a lot of times. So if you just lower your volume because it
might get annoying. If you click on Purchase
on something here, you purchased a couple of times. You can see when the enemy dies, it plays a lot of times. And this is a bit annoying. Let's go to the enemy base here. Let's take a look at the death. If I just make a print string, just print string to
see if this is playing. A couple of times, I
can click on play. I can again buy something. I can see it is playing
a lot of times. Let's go ahead and
fix this issue here. We can use something
called a one node. Let's take this and say once, and go ahead and
select this once. Then it's going to
play this sound effect or basically all
of this code here. One time only I buy something. You can see now it is fixed because it's only
going to play once. This is resetting
basically automatically. Because remember, we are
destroying the actor. Every time the actor dies
and a new actor response. So they will have
a new one, node. We don't really need
to reset this one. Everything is working well here. Let's close it down
and let's move on.
109. 12.05 Adding Music: As the final thing for the sound effect,
let's add some music. And this is super simple, so if we just open up
the audio once again, we can drag in this
music into here. I'm going to click it again. Also reduce the sound. I'm not sure how loud it is. 0.2 is fine, I think so.
Let me close it down. Now we have this. I'm just
going to say by 0200, it doesn't really
matter where it is. Now if you click on Play, you can see you can
hear the sound. This is super simple and adding music and it's
going to loop forever. Everything sounds nice. Okay. Let's go ahead
and save everything. And let's move on
to the next one.
110. 13.01 Designing the Ascension UI: All right, so now let us
work on the Ascension. Basically, what Ascension is, if you don't know already, is whenever you
reach a progress, certain progress in the game, you can press a restart button. It gives a replayability
to the game. When you restart the game, it gives you more base damage. For example, everything
is 300% more damage. Can restart the game basically
and have more damage. And you can basically continue because at a certain point
if you don't restart, the game will become too
difficult and you have to restart to get that bonus
damage to continue the levels. Okay, let's go ahead and start with the
Ascension mechanic. So the first thing I
want to do is basically design the UI and get
that out of the way. Let's go to the UI folder. Let's right L here, make a new widgets. Let's call this one
Ascension pop up. And we'll be working with the
pop up in the next lesson, But for now, now we have that finished. Let's
go over to the Main. Let's add the Ascension
button down here, and we'll make it
appear whenever the criteria has been
reached. Let us begin here. First, what I want to do is take this overlay and drag it
down to the canvas panel. Let's just minimize all of this. Now we have this overlay. I want this UI to be A, down here at the bottom, anchor point, down below. Let's rise 00 in the
position x and y. Now for the x, we have to rise 0.5 For the y in the alignment,
we have to write one. It is up here in the screen. Next we need the UI. Now first let's add an image. Adding this image, this will
be the background image. It will be the same
one as this one. I'm just going to
copy this image. Click here, paste it. Now we have that finished. Next we want a vertical box. Let's add a vertical
box to this overlay. What I want to have is some
text and a button beneath it. Let's add some text. I'm just going to
copy one of them. For example, this
one, control C, go down here, control V
into the vertical box. Let's also add the button, and we can add that by just
going into this level card. We can click on all of this, copy paste it here
in the vertical box. And I can remove this
skull. Now that was it. Let's click on this image. Let's make it fill
horizontally and vertically. Now let's click up
here on the overlay. And let us just resize things, or basically what you can
do is just size to content. I think I'll do that instead. Next we can add text
for this button. I'm going to write Ascend here. Here we can write
Ascension available. Now for the
background text here, I'm actually going to
copy this outline color. Go down here and paste it for this one so they
have the same color. Also, we can click on this vertical box and we
can give it some padding. If you write something like 50, maybe not that much. If we click here
again, let's write 30. Maybe something around 30, 35 is something like this. I think that looks nice. Now let's give it
some spacing at the bottom so it
doesn't hit the edge. And that is the position in
the Y -30 position, the X. Let's write zero. Once
again, go ahead and compile. You can click on plate to
see what it looks like. I think it looks like maybe
this text is too large. Instead of 24, let us write one. Let's also give it
a bit of a space. I'm just going to click up here. Give it some padding
to the bottom, for example, four, compile
and click on play. I think that is nice. Now we have this
ascension available, and we have some sound effect
as well for the button, That was it for this UI. Let's close it down and
continue in the next one.
111. 13.02 Designing the Ascension Popup: All right, now it is time to
design the Ascension Pub up. And we can do this easily by
just copying this for now. Copy all of this we did in the last lesson and open
up the Ascension Pub Up. Pace this down here.
Now instead of here. Actually let's add
a canvas panel. That's why it looks so huge. Add a canvas panel and
then add it into here. Make sure that when you
click on the overlay, it is anchored to the middle. And 0.5 in the alignment
for the X and Y. And also 00 in the
X and Y position. And up here, select
desired on screen. All right, so what I want
to do here is I want to, you will restart progress
but with 300% more damage. For example. We can always write a dynamic number for
this percentage of damage, but for now, let us
write it like this. If you want to make it a bit
smaller here in the width, you can always go down here and in the wrapping you
have this wrap text at. I'm just going to
increase this and we can basically wrap this text
to a certain number. Let us wrap it at
something like 360. I can see that the
image is actually blurry in the background
instead of image. Let's change it to
a box and write 0.5 That looks a lot better. Let us also do that actually in the main. I don't
think we did that. Going back, clicking on it, changing it to a box and
writing 0.5 Let's go back. Now, over here, I'm going
to duplicate this button, but we need them in
a horizontal box. I'm going to search
for horizontal box. Go ahead and add it here. And add this button to
the horizontal box. And duplicate this overlay. By clicking control D, we can click on the first
overlay. Click on Phil. Click on the second
overlay. Click on Phil. Now the first one is going
to say As, That is fine. The second one is
going to say cancel, because we want to go back. If we don't wish to continue,
we can click on this. We can change the color just to make it a
bit more unique. The cancel button is a bit more red, something
like this here. And I'm going to
copy this color to the hover and to the pressed
as well, for the as. I am going to change
the color as well to something a bit more
green like this. Okay, this into the other ones. Here you have it. If
I compile and save, now we have this finished. Let's move on to the next one.
112. 13.03 Opening the Ascension Popup: All right, now it is time to add this ascension pop up to the UI. If I go back to the
player control, remember this is where we
created all of the UI and we created this show
hide widget function. Let's open up the
show widgit function. We will realize that
we need to add it to the enumeration. Let's
go ahead and do that. Let's open up the, let's
go to the game widgets. Let's add the Ascension up. Let's just save here and go back to the
player controller. And now you see you
have a pin for it. Now let's copy this part
widget and let's search for, let's see here, Ascension
pop up, right click. Promote this to a
variable and call it ascension pop up,
just like before. Let's take this ascension
pop up and convert it into a validated get when
it is not valid. We're going to create the UI. However, whenever it is valid, let's drag from here and
say add to viewpoint. We're going to add
it to the screen. If it is valid, let's go ahead and just add
it to the screen. It doesn't make sense to create
it if it's already valid. Let's add this one
here and push them up. Now let's go back to the
hide widget over here. What we need to do is
whenever we close the widget, let's drag this ascension
pop up, right click, and convert it into
a validated get and connect it and
remove from parent. Whenever we want to close it, we can remove it from the screen by saying remove from Parent. I save everything. Now
we are ready to use it. Let's go to the blueprints, or actually to the UI. Now this happens whenever I click on the button
in the main widget. If I go here, this button here, I'm going to change the
name to Button Ascend. I'm going to the graph. Now here you can click on it and click on the clicked event. What should happen when
you click on this button? What should happen
is I want to get my play controller
and show the widget, the pop up menu. I can see here, I don't have a player
controller variable. I'm actually going to
create it up here in the event event
construct like this. Let's just like before
get player controller, then let's get play
controller reference from the blueprint interface. And right click promote this to a variable call
player controller. Now we have this.
Let's go down here. Let's drag this
player controller and say Show Hide widgets. Let's go ahead and
select Canine Pop up. Let's click on Show. But we also want to hide the main menu. I actually main basically I'm going to drag this as well
and say Show Hide Widgets. I'm going to hide the main UI. It's already sit like this. Compile. If you click on Play, you click on assent, you
can see that it appears. Let's actually do
the same thing here. Let's remove this
from the screen. Whenever we click on pencil, let's call it button
pencil up here. Let's go to the graph and click, Let's delete all
of this for now. Again, we need the
play controller. So let us go ahead and
do that event construct. I'm just going to copy
it from the main here. Just copy all of this
and paste it up here. Just like before, remember to click on this
flight control line created as a variable like this. So now we have it.
Let's actually, let's just copy paste here. We don't have to write all the same stuff again and again. Whenever we click on the cancel, we want to open the main UI, but we want to close
the Ascension pop up. Let's try that. Open it up, click on Cancel, and I can
see it is working just fine. Go ahead and save everything, and let us move on
to the next one.
113. 13.04 Setting the Restart Game Event: All right, now whenever we
click on the Ascend here, actually I'm going to
delete the music just so we can work here
without the music. I'm just going to click on it. And then click on the
volume multiplier to zero. And if I click on play now whenever I click on
Ascend and Ascend here, I want to restart the game. This is basically
what I want to do. We're basically restarting
the game and giving the player amount
of damage extra. Let's go ahead and
restart the game. The way we do this,
let's actually do that inside of the game mode because this is where it makes
the most sense down here. Let's right click, make
a new custom event. Let's call this
one restart game. There are a lot of
variables we need to restart because
we actually need to restart all of the variables that we have been
working with so far. Not all of them
but the ones that are very important and
displayed to the screen. Let's begin, for example, with the level you have
unlocked and the current level. Let me just drag
this unlocked level, drag it in, and set it to one. Again, this is what it
was from the beginning. The same thing with
the current level. Let's drag it and set it to one. Let's also remove all
of these buttons here. When you have all
of these buttons, you need to remove them. Let's do that by getting
the player controller. Let's find the Maui.
Go ahead and get it. Then we need to get the level list. This
is what we called it. If you don't remember
what you called it, you can always open up the Maui. You can click on this list
and you called it level list. We're getting this menu. We're getting the level list. Go ahead and get it. We can drag from here a clear children. We're going to remove all of the children child components that are inside of this list. Whenever I remove all of them, remember we also
remove level one. We need to add
level one as well. The way we can do
this is right from the player controller
and we have this one called a button UI. If you don't remember this, which is natural because
we have been working with this in quite some time and sometimes I also forget
myself, what I called it. It's always nice to go
back and see a button UI, Basically adds this current
level to the server list. If I go back to the
game mode and we add this level button
UI, it is level one. Basically the unlocked
level we have here. Let's drag the unlocked
level and add it. Now we have the levels correct. The next thing we
want to work on is the amount of coins
the player has. We need a reference
to the player, and I can see we don't have
a variable for the player. Let's actually add one up here. Let me drag all of
this. Now this one is in the begin play. In the begin play,
let's right click and say get player character, let's say get player reference from the blueprint interface. Go ahead and connect
it. Let's right click and promote this
variable called player pawn. Let us connect back to this one and just push
them back again, Compile. Now what we can do down here
is we can take this player on and we can say
amount of coins. We can set the amount
of coins to be zero, but we also have
to update the UI. I don't fully remember
the logic here. If I go back to the player, open up the player here, we updated the amount of coins. And it is this one
in the WB main, we called it update
coins amount. Let's just copy this
part of the code. Let's go back to the
game mode, paste it. We basically don't need
to write more code. We can just copy
paste the ones we already have and connect it. Make a rear route node like
this. And now this is set. Okay, the next thing
we want to fix as well are the amount of
items here we have bought. So we need to restart
that as well. For the items port, we have this variable item spot
inside of the player as well. If I go back to the game mode, I copy the player pan
here and I search for it bots ahead and get
this correct from here. And then say clear,
you'll clear all of the values inside of this
map whenever I clear them. I also want to update the UI. When you update the UI
for the item cards, you basically just
recreate all of the items. Because remember, when we
created the shop item cards, we basically cleared
the previous ones. We can go ahead and go
back to the game mode. We can take the player
controller here and we can drag and say Create shop item cards. Go ahead and connected. Now the final thing is we also need to update the
DPS for the player. We need to restart the total
DPS and the cursor damage. Let's go back to the game mode. Let's again take the
player like this. Let's take the total DPS, Set it to zero, because this is what
it is by default. Let's take the cursor damage
and set the cursor damage. Now the cursor damage
is 15, I believe. So if you click on
it, you can see the default value for it that
you have set for your game. And I'm just going to
set it back to 15, which is the default
for my game here. And we can just make
a rear art note and everything looks great. Okay, so the final thing is we want to set the current
level we are in, because we have this set current
level and it also spawns the enemy for that
level and starts the round time we
need to do this. Let's go back here. Let's
say set current level. Let us add the level we are in which is
the current level. The current level we
restarted to one Again, here if you remember
the first one, current level set to one
was going to set to one. Now we are finished
with this restart game. Let's actually see
if it functions. If we go back, let's see here, if I just close
all of this down. I open up the UI. I open up this one
ascension popup. I click on this ascent, and I go down and I click on the clicked for
this ascent button. I'm going to copy all of
this because we need to show the main UI and we need to remove the Ascension
pop up as well. When we click on this button, let's change the name for it. It's not the button level, it is button ascent.
Let's go back. Okay, over here we also
want to restart the game. I'm going to right
click and say get game mode and then get
game mode reference. Then I am going to
say restart game. It should work just fine. Go ahead and save and let
us play and try it out. Enemy. I buy something here
and I switch on the level. If I click on assent
and then ascend, you can see that it
restarts the timer. It restarts the amount
of items I've bought. It also restarts the
level progression here and the amount of coins
I have. Let's try again. If I just tell the enemy I
buy something from the shops, we restart all of the progress and everything is
working nicely. That was it for
restarting the game. And let us move on
to the next one.
114. 13.05 Displaying Ascension at End Game: What we want to make sure now
is when you click on play, we want to make sure
that this ascension available is only shown when the player has
reached the end game. We, I'll say for example
in my criteria is whenever the player has bought all of the items
like a certain amount, then this ascension
available will be shown. Let's go ahead and do that. Let's do that inside
of the game mode. Let's open up the game
mode inside of here. Let's create a new function. Let's call this function
as criteria met. For example, it's going to
check if the criteria are met. And then it's going
to show this widget now to make sure it is hidden from the start.
Let's go to the UI. First, let's open
up the main Ui. Inside of the main Ui,
let's click over here. Here on the overlay
for the Ascension. I'm just going to
change the name for this overlay because
we're going to hide it, so it's always nice to
know the name of it. I'm going to call it
Overlay Ascension and set it to is variable. Also as a start here
in the visibility. Instead of not hit testable, let's set it to collapsed. It is not in our view. If you clip play now you can
see it is not shown anymore. We're going to show it whenever
these criteria are met. Now the criteria, whenever you have bought a certain
amount of these items, it will show we need
the item spot map. This is inside of our player. Let's get or get a
reference to the player, and we already have
that here. Play on. Let's take it out
and say item spots. Let's get this map we
created previously. Now we need to get all
of the keys from it. The values, they're
basically called keys. All the keys here. We also
can see the values for them. Let's strike from
here and say keys again and drags,
then connected here. Now we have all the keys. What I want to check first
is do we have all the items? Because it doesn't really
matter to loop all of this and check how many items we have if we don't
even have the item. Just for optimization's sake, let's first check if the
player has all the items before we loop
through them and see how many there are of each item. Let's take this and say
the length is this length, is this equal? Go
ahead and select that. Is this equal to the amount
of shop items you have? And how do we get how
many shop items we have? This is actually super easy because we can now
here in the game mode, let's define that in the
player in the begin. Play here in the
game mode after I define the pawns
and spawn points. Let's actually do that
before we spawn the enemy. Disconnect this one
and let's strike from here and say get data table. So far we've been
using this one. Get data table row but
now let's use this one. Get data table row names. We're going to get all
the data table row names for the info data table. Here are all the names for the items from this
and saying length, this will tell you how
many items we have. For example, if you have
11 items, it will say 11. Let's right click this one
and promote it to a variable and call it amount
of shop items. Go ahead and connect it. Now, like this,
connect this as well. Now what we can
do, let's compile. If you want to see what it does, you can always make
a print string. Always use a print string if you want to see
what you're doing. It's an indicator. You can click on
play, and it says 11 here to the top left. That is working perfectly. Let's compile. Let's go
back to the criteria met. Let's strike this amount
of shop items into here, and then let's make a branch. What we're basically
doing is we're getting the keys for the items, we're taking the length of it. We're basically checking how many of these items
have we bought. And we're comparing it to
the amount of shop items. If the amount of items we have bought is equal to the
amount of shop items, this means I have bought all of these items at least once. After I know that I bought all of these
items at least once, the length of the items pot will be the same as the
amount of shop items. If that is true, let's go
ahead and continue the code. If that is not true, we can, we can just leave it because we don't want to do anything. Let's continue from here.
And now we want to get the values dragging from here. Or you can basically,
just to make it cleaner, you can always drag here again and then drag
and say values. Now you're getting the
values of those keys. Basically the keys are here
and the values are here. Now you're playing
on the values here. Now for the values
you're going to say for each loop with Brick. Taking this one, what
we want to check is if we have bought a
certain amount of that item, for example, let's say
the player has to buy at least ten items
of each before. The ascension appears. We're going to look
through all of the item values and
we're going to check if they are at that
amount of bot amount. Basically whatever we set, if I say is it greater or equal
to whatever I write here, for example, is it
greater or equal to ten and I can make a branch. Then what I want to do is I
want to create a counter. Let's do a local variable. And I'm just going to
call it local counter. It's just going to be a
counter that counts for me. It starts at zero. We're going to say this
counter plus plus. Every time we find that
this criteria has been met, we're going to add
one to this counter. If we have bought ten items
of each of those items, then this counter should be 11, because we have 11 items. Whenever it is 11 here
in the completed, it's going to loop
through all of them and it's this local L plus, which means basically
plus one to it. If it was zero, it will be one. If it was one, it will
be two, and so on. It's going to loop through them. And if this local counter is equal to the amount of
shop items, which is 11, basically this counter
will be 11 if we have bought this certain amount of items from each of those items, because we have again 11 items, let's make a branch
and say, is this true? If that is true, we want to say that the criteria has been met. I'm actually going to
make a new variable here. And it's just a bullion called
ascension criteria met. And change it into a bullion, go ahead and connect it
here and set it to be true. Yeah, that should be it. Actually what we're doing here. Let's make a break,
by the way, here, because we don't need to loop through it without breaking it. Because here we're using a
for each loop with break. And what that means is we're
going to loop this code. However, it doesn't make sense to keep looping
through them. If we found out that for the light feather
we haven't bought ten, why should you loop
through all of them? Because it's not
going to show anyway. Because this one is not ten. Instead of, this is
basically for optimization, so you don't loop through the
code without any meaning. If we loop through it and
we found out that one of the items doesn't have
ten items. But as we wrote here, then we can
drag here and say break. We're basically
breaking the loop. What we're saying
is, for example, we're looping through, we're taking a look
at the light feather. It says, for example,
yes, we have bought ten. Then we're plus plusing
the local counter. Then it takes a
look at the torch. And maybe we only
have bought nine. It will say false, you
have not bought ten. If that is false, we're just
going to break the loop. So we don't loop through this anymore because it
doesn't make sense. We haven't bought all
of the items ten times. It's going to break the loop and it's going to get completed. The local counter is not equal to the amount
of shove items, because maybe it
was only two here. Then it will be false and
then nothing will happen. The ascension criteria
will only be met whenever the local counter is equal to the amount
of the shop items. Now you have to think of
where does it make sense to check for this or
call this function here? Now it makes the most sense in the purchase item basically. Let's go back to the player. This is where we made it. We have this one purchase item. Every time we purchase item, we need to check if the
criteria has been met. Let's just do that here. At the end, it is
in the game mode, so we need to take
the game mode and say ascension. And take this one ascension criteria,
we're going to call it every time we buy something
because we need to check, if we need to show
the ascension, would it Now if you click on Play and buy all of them,
it's not going to show. Because remember, we set
the Ascension overlay. So if I go back to the main UI, we set this overlay
to be collapsed. At some point we
need to show it. Let's go back to
the game mode now, here in the Ascension criteria, and now let's show this overlay. Now remember, this overlay
is inside of WB main, which has the reference inside
of the player controller. If I just take the
player controller and I search for WB main, I get that and then I get the V ascension. This is basically
what I called it. Then I can say set visibility. Let's set the visibility
to not hit testable. Remember visible is
basically going to block your mouse clicks and we
don't want to do that. Let's do it testable,
compile and save. Now, just for testing purposes, let's just write one. If I just disable the
sounds before I click play, I think it will be
annoying for you that I keep playing the sounds
here in the enemy base. Whenever the enemy dies. I'm just going to disable this Play sound to D. For
now, let's click on play. I'm just going to purchase. Each item. Now, this is the last one and I'm
going to purchase it. I can see nothing is happening, even though it should happen. Let's actually this
is a good opportunity to try to debug it together and you can
see how I debug it. Let us go ahead and go
back to the game mode. Basically, the error
is happening here. Let's make print string notes. This is what I usually
do to debug over here. Let's write a print string. Let's say if the
code goes through. Basically what I'm looking at is does the code go through? If it does that,
it means it works. Let's just write first here,
for example, whatever. It doesn't really make any
difference what you write. Let me just write, for
example, second here. Whenever I go through
the code here, what it's showing here
if it says second, this means that the length of these keys are equal
to the shop items, which means the code is
working before I continue. Let's just try and do that. Now saying first it is fine, should say second whenever
I buy the last one. But you can see it's
actually said second. Whenever I bought this one, I haven't bought this one yet. So it actually
things that I have the amount of shop items already before I
buy the last item. Either I have a default value inside of this item
spot by mistake, which I'm going to
look at in a second, or the amount of shop
items are wrong. Let's first take a look at
the amount of shop items. I'm just going to delete
the print string. I'm going to go back to
the game mode event graph. I'm going to print the amount of shop items that I'm
actually getting from this, is it 11, which I'm supposed
to get. It says 11. There's something wrong
with the other variable, something wrong
with the item spot. If I go back to the player
and I click on the items, but I can see here, this is actually
the mistake here. By default, I clicked
on the plus and added a random empty item. And I can click on Delete here, and click on Compile and Play. Let's try it again now. If I buy one of each item, it's going to work now. And it's also going to show
me the Ascension available. I can click on Ascend
and ascend here, and then restart the game. Now we need to hide this again, whenever we ascend, let's
actually do that very quickly. We can do that. Let's
close this down. Let's go back to the UI. And let's open up
this pop up here. Let's do it here whenever
we click on Ascend, Here whenever we click on
Ascend and restart the game. Let's just do it before
we restart the game. Let's take the player
controller again. Past it in, go to the WB main. Then let's get
again V Ascension. Then let us push
this further away. We basically want to set
visibility just like before, but now we want to set the visibility to collapsed
just like before, collapsed and then
connect this one. And then that should
work just nicely. Okay, now everything is working and let us
continue to the next one.
115. 13.06 Creating the Ascension Structure: What I want to do
now is I want to create the Multiplier
for the Ascension. Every time we ascend to a new level or
restarting the game, I want to give
myself more damage. For example, the
player should have 300% more damage than before, and everything gives
300% more damage. Let us set the multiplier and we can do that very
easily through again, a structure and a data table. Let's go back to the
structures and right click go to Blueprints and
then make a new structure. Let's call this
one ST Ascension. You can also call the Ascension multiplier, which is what it is. Let's open it up
instead of here, let's change it into a float. And basically what we want to
do is we just want to have the Ascension Damage multiplier. This is the only value we need. Now let's close it down. Let's go to Data
tables and let's right click Miscellaneous Data Table. And let's select the
structure we just made. You can see in blueprint you basically just do the same
thing again and again. And whenever you get
really good at it, you can basically create
your own mechanics by just using the tools
you have learned. This one called basically
just ascension For this one, let us save and let us now
open the Google Sheets. Basically over here,
let's make a new one. I'm just going to duplicate
this item in for, for example, let's call
this new one T, ascension. Let's delete everything now. For the ID is at what
level ascension we are. We start with level zero because we don't
have any ascensions. This is basically,
you can think of it as the amount of Ascensions we have done or
starting from 01, and you can continue
to how many you want. Then you can say
Damage Multiplier. Basically, you have to
call it the same name, Ascension Damage Multiplier. So the same name as what you have wrote inside
of the data table. Now for the multiplier, it has to be one when you are at zero ascensions because you are going to multiply
everything by one, which means you're just getting the damage you just
had previously, which is basically
the base damage you have defined here
in your item info, everything multiplied by one. Now, whenever we ascent, you can for example, say three. This means you now have three times more damage
than previously. And then you can say,
for example, seven. And I'm just going to
write random numbers, I'm going to say this
times 1.5 or whatever. And you can just drag
down and then click here to remove all of
the decimal places. Now we can just use this. Okay, Let us go ahead and click on File Download,
download CSV. Now I have this DT ascension. And I'm going to go
back to my engine. And here we can now drag
it in it into here, and it should load
everything correctly. All right, now you
have the multipliers. And let's continue by
going to the libraries. Open it up. Let's make
a new function here. Let's click on Ad,
click on function, call it y as multiplier
for example, or ascension damage multiplier. You can call it
whatever you want. Now for this input, we basically have to know
what level are we in? How many Ascensions
have we done so far? Changing it into an integer, we can call it Ascension Level. Now let's say a table
just like before. Let's get the
Ascension data table. Now again, you can't
connect this to this because you first have
to say, two strings. You have to convert
it into a string, and then you can
connect it here, and it will automatically
convert it to a name for you. You can drag from
here and say return. You can return the information here by dragging into this. And now you can say Ascension
info, for example, compile. And remember to click on this
function and click on Pure. Again, we're just getting
some information from here. Let's save everything. And now we can use it in
the next lessons.
116. 13.07 Adding the Ascension Multiplier: Now what we have to do
is we have to multiply all of the damage we are doing in the game with the multiplier. So we are getting the correct
amount of damage out. To do this, we have to know where did we do
all of the damage? We can easily find this. Let's first go to the player. Now, in the player
here, for example, in the purchase item
we did this, TPS. Now what you can do is
you can always right click here and click that's. What I would do is find references for this because
we have the DPS here. If we can find all of the references here in
all of the blueprints, we can find where we are doing DPS or where we are
taking this information, right clicking Find references, and then clicking on
this small icon to find the references
inside of all blueprints. Not only this one. Okay, I'm going to put this on my second monitor
and I'm basically just working with
this one first. Now what I want to do
is I want to multiply this amount of DPS with
the Ascension multiplier, I'm getting the
correct amount of damage compared to the
multiplier of the Ascension. I'm going to right click and say Get Ascension Damage multiplier. We can take this
and say Break now, we can multiply
it with this one. Maybe I should have called
it something shorter, but it's always nice to have a descriptive name to
know what you're doing. Basically, when we
get this DPS out, we want to take this
and say multiply. And I'm just going to disconnect it from
here and put it here. Doesn't really make a
difference, but looks better. I'm going to multiply the
DPS with the multiplier, then I'm going to drag this now and plug it
into here instead. Just drag it down, so it
looks better like this. Now we are multiplying the
multiplier, so for example, if the multiplier is three, we can say three times the DPS. And it will show or increase the cursor damage
by the correct amount. Now we need the essential Novel. We need to know what
level are we in? Let's create this variable
inside of the game mode. If you open up the game
mode and inside of here, let's create a new variable
called Ascension level. Let's change this
one into an integer. Compile for now. We haven't really made anything with this ascension level, but it doesn't really
matter right now. Let's go back to the player
and let's take the game mode. Now if I can find it
here, game mode level. And we can just take this get Ascension level and go ahead and connect
it with this one. We're basically getting
the ascension level, which right now is zero, if the ascension level is zero, if you go back to the data
tables at the level of zero, you're going to get the
multiplier to be one, which basically means that
the DPS multiplied by one, which is just the DPS here. It's not going to
change anything. However, if you ascend
the first time, so you have level one ascension, you're going to ply all
of the damage by three, which means you have
300% more damage. Now let's find all of
the places we have DPS. And I'm just going
to copy all of this code so you don't
have to write it again. Copy all of this code. Now I'm going to take this
into here again. Click on the first one,
it's just this here. Click on the second nine. Info, we don't do
any damage here. Click on the third one, we don't do any damage. Click on the fourth one, here we have some damage. This is inside of
the function update. Total DPS update total DPS. We're going to do this, then we are going to
take this DPS again multiplied by the
ascension damage multiplier and
plug it into here. By the way, I can
already see that we have a bug here because we are updating the total amount of DPS by getting all of the
items we have bought. We're getting TPS for them, and then we are adding
them into the total DPS. This is actually also
happening with the mouse here. It's actually adding
this to the total DPS. What I want to do here
to avoid the bug is I want to click on the item. Then I'm going to say not equal. And go ahead and select
not equal to mouse click. We don't want to add
the mouse clicks DPS into the total DPS. A small bug that was here. Let's just make sure
we don't add that. And I'm going to make a branch. Go ahead and connect it
here. And connect it again. And now it should
work just fine. Now, I'm just going to
restructure things again. All right, now this
is finished and we are multiplying this by
the ascension multiplier. Let's continue to the next one. If I just go back and find my references from before
and click on the next one, here we are doing DPS as well. This is updating the
tooltipI. Again. Paste it in. Go ahead and multiply this
with the Ascension multiplier, and reconnect it here. Now we are multiplying
correctly. Compile And we have a bug here. It says, we don't have
the game mode reference, and we actually don't. Let's go ahead and get
the Gamode reference. Now, before I do all of this, I'm going to say
get game mode and then let's say get
game mode reference. And go ahead and connect this. This, I'm going to just strike
from here and connect it. Now you can also again, right click and promote this
to our variable if you wish. Let's just do that actually
to make it a bit more clean. Connect, you can
do it both ways. Either just connect
it directly or now take this game mode variable
and connect it down here. That is the same
thing. All right, let us now compile also. Let's make sure
the cursor damage is being displayed correctly. And it will be displayed correctly because we
are already multiplying here in the player
whenever we did the increased cursor damage
inside of the player. Here, whenever we
purchase an item we already multiplied by
three for example, and we plug it into
the cursor damage. This cursor damage
should be correct. This damage here is already now multiplied by the
accession multiplier. So this is correct as well. Now let's go over
to the references again. Click on the next one. No DPS here. Click
on the next one. No DPS here either. Now, everything should
be working just fine. Now, just to make sure that the ascension damage is
displayed correctly. Now let's go back to
the game mode here. Every time we restart the game, let's take this ascension level
and let's say plus, plus. We're going to add one to the Ascension level
every time we ascend. So we are getting the correct
amount of damage into this. Now let's go ahead and try this. If I click on Play, and
I buy one of each here, I'm going to buy the last it, and I'm going to
click on Ascend. This one is not really
displayed correctly, This is just a static text. But let's click cancel
and see the damage here to see if it is actually
displayed correctly. I, each mouse is getting it gives 25 DPS and each light
feather gives five DPS. So this should display 15. For example, if I click Ascend, and click on Ascend here. Now this is displaying 15. This is displaying 75, which is all correct. So now I have triple the damage. Let me just try to play, and let me try to ascend again. All right, so now I'm going
to buy the last item here. Click on the last item. I can see this again.
I'm clicking on Ascend. And then ascend once again. And now the light
feather damage is 35, which is correct, and 175, because now the
multiplier is seven, everything is working
correct because seven times five is equal to
35, which is correct. And now we have the
correct amount of damage. Okay, now this is working. And also just to make sure
that we are optimized, let's go back to the check
ascension criteria met. Whenever I create loops, I always pay attention
to if I'm actually running this loop
in necessary times. For example, here we're running the loop
which is correct. However, do you
really need to run this loop whenever the
ascension criteria is met? Because now you know the
ascension criteria has been met. You don't really need to run this loop again because
you know it is met. Take this bullion here, ascension criteria met at
the beginning of the code. We just want to run this. Ascension criteria met
this function here. We want to run it whenever
this one is false. Let's drag from this
and say bullion, ascension is not true, which means it's
false. This is false. We want to go ahead and check if the criteria has been met. However, if this becomes true, we're not going to run
because we're just basically getting false and
we're not running the code. We don't want to run
all of this code. The ascension criteria has been met already because
it is unnecessary. We already have
met that criteria. Okay, remember we have to make this to false at
some point because else next time you ascend this is
going to be true by default because you set it
to true down here and you never set
it to faults again. Let's go back to the
restart game after this. Remember to take the ascension
criteria met and set it to false whenever you restart the level or restart
the game here. Go ahead and save everything and let us move on
to the next one.
117. 13.08 Displaying the Ascension Multiplier: All right, at this
final stage we have to display the correct amount of
damage that is multiplied. So if I go to the UI here
in the ascension pop up, we basically need to display
the correct amount here. Now I'm just going to
write a fake number, so we can actually see that we are changing it dynamically. So I'm just going to
write 00 for now here. Let's now go to the graph and we basically need to
change this text. Now it's called
text round timer, and I'm actually going to change to text Ascension instead, so it makes more sense.
And let's compile. And now we can set this text whenever this pop up opens up. Whenever I click the
Ascent button pops up, and we want to update
it immediately. We can do that inside
of the event construct, which is played whenever
this pop up is opened. Let's do it here. What we want to do is we want
to set the text. Let's take this text
and say set text again. We have to use a format text because we are changing
things dynamically. Again, direct from here and say format text. Go
out and select it. You can see we're using the
same nodes again and again. If you just keep practicing, you will remember all of the
nodes and you will basically know what to do whenever you have to create a
new mechanic yourself. Let's go back to designer. I'm just going to
copy all of this. I'm going to paste it into here. It will say you'll
restart progress, but now we need these curly
brackets here instead. And say damage percent, percent like this,
then more damage. It's going to say you'll
restart the game, but with, for example,
300% more damage. Let us try and do that. Let's connect this one first. Now what we need to use
is just like before, we need to right click and
say get Ascension Multiplier. Because this is basically where we're getting the
information from. We're going to break now again
for the Ascension level, we need the game mode to
have this information. Let's drake everything here. Let's say get game mode. And then let's
strike from here and say get game mode reference. Let's go out and connect it. Now here for the game mode, we need the Ascension level. Go ahead and get the
Ascension level, and you can connect
it into here. How do we get the percentage? Now we're getting
the Ascension level. What we need to do
is we need to get the multiplier after
we restart the game. Because basically what you're
doing here is whenever you open up this pop up and you're only getting
this ascension level, which is zero right now, because you start at
ascension level zero, it's going to say one, basically 100% Now we need to divide the multiplier
which is after, if I just open up the data table so it is more understandable, what we need to do
is we need to divide this number that comes
after whenever we ascend what the number
is here divided by the current 13/1 And you can always just drag this
into the view and say 3/1 that is three times 100, that is 300% Now if you just
try it with the other one, if you try it with the seven, let's say we ascended
one time and I am at level one and I need to show how much damage percent you're going to get increased
when you go to level two. Now we're going to
say 7/3 times 100. That is equal to 233% more
damage from here to here, which makes total
sense. Let us do that. What we need to do is we need to take this ascension level, add one to it, because we need to get what the next ascension level
multiplier is. Now when we have this
information, for example, it is seven divided,
for example, 7/3 which is the current
one, the current one. We basically need to
copy all of this and we need to delete this plus one and just go
out and connect it. We're basically saying, what is the next multiplier damage? We're dividing this
by the current one. Then this needs to be
converted into percent. Now you can do it in two ways. You can either take
this and say as percent and you can go out and select it and connect it here. Now, I don't like this
method because it's going to show you
the decimal places. For example, if it is 7/3 here and we say
multiplied by 100, it's going to say
233.33 I don't like the floats or the decimal
places I want it to be without. Instead I'm just going to say multiplied by 100 like this. Then you can either say floor
and you can read about it, if you hold the mouse over it, it says -1.6 becomes
-2.1 0.6 becomes one, or you can use the
one called round. And this one is
basically the opposite. 1.6 becomes two, and so on. I'm just going to say floor. It's basically going to remove the decimal places and then it's going to
display this to you. Now this should work just fine. Now if I connect it here and
it's going to set the text whenever I open this pop
up and I can compile. And let's see if
it works now if I buy each of those
items like before, and then I can click on As. Now it's going to
say we'll restart the progress but with
300 more damage. Now we need the percent,
obviously, the sign. So let's go back and
just fix this quickly. If I just click here
and set a percent sign, that should work,
just fine compile. All right, so now
I'm going to buy the last one and I'm
going to click on As. And now it's going to show
me 300% which is correct. Now I'm going to
click on Ascend, and I'm going to
again play the game and see if everything
is working right now. I'm buying the last item once again and I'm going to
ascend the second time. And now it's going to say you'll restart the progress part with 233% more damage, go
ahead and ascend. And now you can
see everything is multiplied just correctly, okay. So that was it. For now, everything
is working correctly. And now we can continue to the next section where
we're finalizing the game. And we can go ahead
and clean everything up and we can package the game. So let's go ahead and jump
into the next lesson.
118. 14.01 Cleaning the Project: All right, so now we are
finished with the game and now you have to
clean up the project. Now, what I usually do is
if I have a larger project, I clean it at least
one time per week. So maybe every Friday, every Saturday, I don't know. Usually, I don't
clean it every day because the code
changes constantly. So sometimes you
clean something, but you have to change
it the day after. It doesn't make any sense
because you have to re clean it again so
it's too much work. I'm usually cleaning it one time per week or two times
per week maximum. So let's go, for example,
to the blueprint. I'm just going here
in this lesson. The purpose is to give you tips on how to
clean the project. And I'm also going to clean this project and give it to
you as the final project. For example, if we started
the play controller. So if you open up the play
controller here and you open up the event graph and
you see it's a bit messy. What I usually do is, for example, up here, you can select all
of the event, Begin, Play here, and click
on by click on C, You create a comment and I can, for example, write begin, Play. I know it's Begin. Play.
Whenever I zoom out, I can click on this
comment as well, and I can click on
the show bubble. When zoomed, I can see this
whenever I'm zoomed out. I know this is the begin play, so I don't have to zoom in
constantly to see what it is. You can also click on it and change the color of the comment. You can change it to
whatever you want. You can change the color here, change the alpha, and
so on. Click okay. Now you can also
save this color by clicking and dragging
this up here. Clicking okay. Next time
you create a comment. For example, this
initialized player, you can click on C. For example, you can write Initialize Player. You can click on Show
Bubble and Zoom. For example, you can click
on this comment color. And you can now click
on the saved color up here. And click on okay. I'm actually going to
do this throughout this project before I
hand it over to you. The second thing
you can do is you can also click on
these variables. And you can give them
here a category. For example, I can say widgets, and I can hit Enter. And now you can see it is
in a widgets category. If I click on the next
widget down here, I can click here and I
can click on the widgets. And I can basically do
that for all of them. All of the widgets are together
inside of this category. And you can see I
can minimize it. Now they are inside of here. This is also how you can clean up all of the variables
that you have. Go ahead and compile and
save everything now. Basically you can do that
in every single blueprint. For example, going
to the game mode. In the game mode,
maybe I can put all of these spawn
points together. So I can write a category called it spawn points, for example. And I can basically drag them into here. Just go
ahead and do that. Go ahead and clean up your
project. Create commons. Now the third thing
I usually do, again, go ahead and
create reroutes notes. As you have learned,
double click. Create some reroute
notes and try to clean your project
as best as possible. What I usually do as well is I reorganize all of the
events I have created. For example, these ones
are the shop item cuts, this is the spawn item. For example, you can
go ahead and take this and paste it here beside this
and maybe comment this out. You can also go back here and see if they
are in the correct order. For example, if you want this to be down here instead, and so on. So just go ahead and try to organize it as best as possible. If there are some things you
want to wish to convert into a function instead of an event,
you can do that as well. For example, let's say
this restart game. If you want to do
it as a function, let's actually go ahead and
make it into a function. Usually for functions
you can't convert things into a function if
they are timed events. For example, if I have a delay. You can see this icon here
means a timed event, fy rod. Click this and say
collapse to function. It will give me an error
because you cannot convert functions
into functions. Fight, click and say time line as well and add a time line. This one is a time one as well. I can't right click and
collapse to function, This will give me an error. I can see this by
looking at the icon at the top and I don't
have anything time. I can basically change
this into a function. I usually do that
sometimes because if you create too many events
in one event graph, it will actually start to. If you have a large enough game, it will start to here whenever you go into
this blueprint. Now you can either
make these events into functions or you can
make new event graphs. If you click up
here on the plus, you make a new event graph. For example, we have done this in the first
person shooter course. For example, you can
call this one ascension. And you can have all of the ascension code inside of here. If it is a lot of code, what you basically can do
is you can copy all of this basically control x to lip it out and you can go to
the next even graph. You can click control V. You now have it inside
of this even graph. You don't have to see it here in the normal one, but
you have it down here. Instead, just going to click control Z because we don't
really have much code here. I'm going to delete
this even graph if you want to make
things into a function. You can also do that by going back to the
event graph here. Then what you do or
what I do usually is I can select all of the nodes
here without the event. I can write click collapse
to a function again. Usually I call it to begin with. If I just drag it into here, I call it restart game. Then I write click on this event to see
where I have used it. Find references and
click on the icon, all of the places
I have used it. These references are
basically just this one, It's not what I've used. Clicking on the next
one, Restart game. Down here I can drag from this game mode now
and say Restart game. Now I'm using my function
instead of my event. I can delete this and
I can connect it here. I just compile here, Go back to the game mode, delete this event now. And delete this function,
because now you're basically using this function
to restart the game. I also use this method sometimes to clean
up my event graph. When I can see
that some events I don't really necessarily need, I can change them
into a function. Now, what is the
difference between this function I've
created and this event? Absolutely nothing. It basically just cleans up your event graph. Now you can see it
gets more clean. And even if you
want this unlocked level to be a function, you can do that by collapsing
it into a function. Remember to right click
this, find references. Go ahead and click
on the small icon. Wherever you have used this
here in the enemy base, you can make it
into a function and you can use the function
version instead. And then you can
delete this one. Just go ahead and clean
up your project this way. Go ahead and remember to
save your project always, and let's jump
onto the next one, or we package the project.
119. 14.02 Packaging the Game: All right, so now it is time
to package the project. So we can send it
to friends and they can try to play it
or family as well. So to do this first
before we package, I'd like to have the
debugger or the log open. So output logs if
you just click on Window and Output Log
and to show this. So now we can see if we have any errors when we export it. Now before I do this, I'm going to right click
here and clear the logs. I start from fresh, so I can see what's
happening right now. Clicking on the filters up here, you can see the messages
warnings and errors. Sometimes I just remove
the messages like this, I can only see the
warnings and errors. This is basically
what's important, so we can fix those. But for now, let's
take the message on. Let me minimize this a bit so I can actually
see what I'm doing. Just like this, clicking
up here on the platforms, going to Windows, and
then selecting Shipping. Now when you select shipping, you also have to
go basically here. Let me just close this for now. Going to the Edit
Project Settings, in here, you have
to go to Packaging. Now inside of the packaging, what is important is
the Advanced over here, clicking on Advanced.
Then let's go down. Now in here in the Advanced, you have to include
the maps you want to package here in the list of maps to include
in a package build, you have to click on the plus, then you have to
click on the maps. Clicking on these three dots, select the maps you have. If I just now we are
inside of the project here in the content folder and we
created this maps folder. I'm going to select
this map, Dungeon. Basically the main
map we are working with clicking on Open. Now, if you have any
movies, for example, when games start up and they
have a start up screen, start up movie, you can go ahead and include that as well. If you have directories that
are extra in your engine, you don't use them, you
can also add them here. But basically this is all
what we have to do here. Also for the project
built configuration, I'm going to change it
into shipping instead. And it says if project has code or running a
locally built editor, I'm actually for the build I'm just going to
say always build. Whenever we make it into a
shipping here for the rebuild, I'm going to click
that or distribution. I'm going to tick this as well. And now you are ready now
to make it better as well. Go ahead and click on
the Project Settings. Once again, up here, search for smooth FPS, here, smooth frame rate. This is really important to tick, because if
you don't do this, it's going to run your game at the highest FPS that the
player's computer can run at. I did this with Farm Tail to begin with by mistake because I didn't know this
option we run at, for example, 500 FPS. 600 FPS. And it's really going to hurt their computers
because they're going to run super fast
and you can hear the fans running super quick. Clicking on this,
I don't need to have more than 60
FPS in this game. It's not a shooter
game or anything. And I can have as
low as 22 FPS if the computer is super slow
on the player's part. But basically, let's
max out the FPS to 62. You can also make it to
122 FPS if you wish to, but I'm just going to let it
be to 62 PS. Close it down. Click on File, Save All. Now you can click on Platforms,
Windows Package Content. But let me just open up again. My window output locks so I
can see what's happening. Right click clear the
locks before I do this. Now also what you need to
remember to do here as well, Click on Filter and
show all as well. I can see all the messages. I can see all of those as well. Just all of
them ticked on. Go ahead and click on Platforms, and then click on Windows. And then go ahead and
package the content. Now I have created a folder here in my desktop
called Packages. Just basically, go
ahead and create a new folder somewhere in your computer, doesn't
really matter. And go ahead and click
on Select Folder, and it's going to
package inside of here. Now it's going to
take some time. The first time it
does this and it, it usually shows a
couple of errors because I have never packaged for the first time
without any errors. Because there are some random errors that appears some time. All right, so now I can
see we are getting a bug here and it says
Unknown cook failure. And you just stop packaging
because we have an error. So click up here and
click on the messages, and let's see what it is. And it says structure property and it says Unknown structure. Now this is a known
bug inside of uneral engine and
it's a bit annoying. I don't know why it happens, but basically it says you
have an unknown structure. Doesn't really make
any sense because we made it and it's working
and everything is fine. But just pay attention to where it is and it is
inside of your UI. Wb enemy info. If you go over to your UI, go to the UI, open
up the enemy info. This is basically
what is telling you. Open up enemy info, go to Graph. The only thing you need
to do for some reason is click on File,
Refresh all Notes. And then this should fix it. File refresh all notes. Then the next one is B
level Cod in the UI. Just minimize this, I go to
the level Cod here as well. Graph file, refresh all notes. What I usually do as well is I refresh all of the notes
inside of the library. Going open it up, click
on the first one, the enemy info file,
refresh all notes. The second one
refresh all notes, the third one just to make sure that we don't get
this bug again. Whenever we cook and click on Save All, now it should work. Clicking on Platforms
again, actually, let me open up the P output
log first, right click, clear the log file or platforms, and then package the project
once again into here. Now clicking up here and show
all messages as well just to see if we have any box now.
Should not really happen. It usually just happens when
it says Unknown structure, you just have to refresh all of the notes
for some reason. I don't know why it happens,
but it's a bit annoying. But now you can
see everything is cooking and everything
is working just fine. We have no errors. It
just takes a minute here. Now, you can always click up here and remove the messages. Now the cook is complete,
package is complete. What I usually do is I remove the messages to see if I
have any errors in my game. And you can see the
project is super clean. We don't have a single warning. We don't have a single era. The game is running perfectly, and this is what we want. Now let's go to the Packages
folder inside of my desktop. And inside of here I can open up this Windows folder
it has created, and now the game
is inside of here. Let's try to run this game
outside of the engine. As I can see, I have
some errors here, issues that I need to fix. But as you can see, the
game is working just fine. I need to reapply
the music and so on. But I can also see the
background is blurry. I can also see this text is
too close to each other. So let's go ahead and
fix this and come back al four To close it down, I'm going to delete
this folder for now. Now let's see what the
blurry problem is. Now the blurry problem
is if you open up, for example, this
dungeon prison texture. Let's go down here in
the texture setting. Let's click on Advanced. Down here you see something
called filter nuclear. You need to change this
one to nearest instead. When you change it to nearest, this means it's
not going to blur your texture whenever you
export it or package it. You actually have to do that
for all of the textures. Now let's see how we
can do this easily. Now if I click on Assets,
and I click up here, go down here, and here
we have a texture, I'm just going to
click on it here. By doing this, we can
see all of the textures we have in the game inside
of this Assets folder. Let's just try to do
that for all of them. Let me just click
on the first one, Shift, look on the last one, right click, and then go to Asset Action Edit Selection
in Property Matrix. We're just trying to do
everything just at once. If I click on the
texture up here again, and I can see this filter, change it to nearest, which is the correct
setting we can save. Then let's see if the
tiles were included here. I can see that the tiles are included.
Everything is fine. Everything is included here. Basically, everything
should work just fine. Okay, now this is done. We also have an
issue with the name. Let's fix that as well. If I just click up here and remove this texture
so I can see everything, once again, I can
click on the enemy. If I go back to blueprints, open up the enemies
and enemy base. And I click on the viewport. Now clicking on the health bar, I just need to move the
health bar slightly below, I believe if you click
up here, click on Play. As a standalone game, you should be able
to see what it looks like here
without trying to package the project opened here on my second monitor and I
can see what it looks like. Now you can see nothing
is blurry anymore. However, as you can see now the level and we can move it slightly down and
the health as well. Let's close it down. Click
on the Enemy Info widgets. I'm going to move it to -25
also for the health bar. Let's try -45 And let's compile
and click on play again. Now. It looks a lot
better when it is full screen and everything looks playable and everything
looks nice If you want to. You can also do
the unfiltered for the UI just to make sure everything is looking
good and not blurry. You can always go
back to the UI. If I go to content,
I open up my images, basically these
items here as well. If I just right shift, right click, selecting
acid action, it selection in property matrix, go to texture and then the filter should
be nearest as well. For those, let me just open
up the textures here as well. This is the hit effect. Just to make sure the hit
effect is not blurry as well, Just open it up and go
again down to Advanced. Change it into nearest,
close it down. Now for the icons as well. Right click, set actions, edit property matrix texture, and then change it to nearest, close it down to fonts. Not really need to
do anything here. Now for the buttons. Again, edit them and make the texture
filter to nearest. Now that is done for all of
them. Let's click on Save. I'm going to put the volume for my music to the
default, which is one. Once again I'm also going to, instead of the blueprints and
inside of enemy enemy base, I'm going to reenable
my sound for the enemy year that
I disconnected. Compile Save All. Now let me just go ahead and try to package the
project once again. Now that the project
has been packaged, let me just go
ahead and click on the Dungeon clicker once again to make sure
everything is working. And you can see nothing
is blurry anymore. Everything looks good,
the UI looks good, All the sound is working. I can play basically just
restarting the coins. That's something I missed, but not really a
problem right now. But you can see everything is working and the list
is working here, and the Ascension is
working basically as well. And I can see it gives
the correct amount of damage and now we have
a completed game. All right, so now we are
finished with the project. And you should be really
proud of what you have done so far because we
have been through a lot. We have done spawn points, we have done enemies damage, we have done all of these
two D putting them together, the UI, coding the UI and so on. So you have done a lot of work, and I hope that you have
learned a lot from this course. And hopefully it was a lot
of fun to learn as well. And if you wish,
you can take a look at my other courses as well. I have a lot of in
depth courses and I'm still creating new
courses to this day. So thank you so
much for watching. I hope you have
had a lot of fun. I did have a lot of fun
creating discourse. And remember, if you
wish to get help 2047, you can always join
my discourse server. We are a community
that loves to help. And we can also talk about things in game
development in general. Or you can show me your work. You can show it
to the community. Really wholesome
community to be around. Thank you so much
for enrolling in this course and I hope
you have a lot of fun. And I'll see you
in the next one.