Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranรฎ)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
In this section, we'll add actual gameplay logic to our pick up blueprint.
Open up the content drawer and open up the BP pickup.
Go to the event graph.
And here you can see that we already have a beginplay node an actor begin overlap node and a tick node.
The Beginplay event will be triggered one time when the actor is initialized.
This could be when starting the game or when spawning the actor.
To demonstrate this, let's click on the arrow here and drag the node away.
If you let go, this context menu will pop up.
Here we can search for print string.
And press enter.
Now when we start the game, we can see here on the left side that hello is printed twice.
This is because we have two instances of this blueprint.
Select one of these and click the delete key on your keyboard.
When you start the game now, you see that it only pops up a single time for one BP pickup.
You can also just right click in the event graph and it will bring up the same menu.
There are countless functions available here and you don't really have to know all of them.
There's probably 10% of these that you will just use over and over again and get used to them.
Uh, many things you know, from programming are also available here, such as a for loop, for example.
And we can just connect this here.
And as an example, put the last index to five.
So this will spin around five times.
We can select the print string node here and press control and C to copy it, then control and V to
paste it in here.
And then just connect the loop body here.
When we start the game now, you can see that Halo's been printed multiple times, which happened because
of our loop.
But now we can just delete this again.
But I hope you understand how important the Begin Play event is.
This is commonly used for many different things, such as spawning objects in your level on begin play,
or maybe putting ammo into your guns and a lot of different things.
For now, let's skip the begin Overlap event and talk about tick.
Take will be called on every single frame.
This actor is active.
This makes it both useful but also dangerous if you don't know how to use it properly.
To demonstrate this again, drag off here.
And add a print string.
When you start the game now you can see that Halo's been printed over and over and over again.
To get a better understanding of what a frame is, we can click here and show this.
And you can see that our game is running at 60 frames per second.
This means that the halo is being also printed 60 times in a single second.
However, this frame rate is not set in stone, and it can change depending on what's happening on the
screen and it can slow down the game.
And as I said, it can be extremely useful because you can update things on every frame.
However, you need to be very careful not to have heavy operations on tick because that can easily slow
down your game.
This is often used for dynamically setting the speed of your character, tracing for objects and things
like that.
I want to show you how to disconnect a line like this.
You can simply hold the alt key and click it.
This will delete it.
Another method is to connect it first, double click it to create a root node, and you can just select
the root node and also click delete.
And these are two ways you can get rid of these lines.
The actor begin overlap event is something I actually don't like to use at all.
Because it is quite ambiguous and you don't really know which overlap you're talking about.
You can just select it and hit delete.
Instead, it's better to use the overlap event on the component that we want to use.
We can select the sphere and scroll all the way down.
And here we have the available events.
The event we want to use is on component Begin overlap, because we want to make it a pickup that the
player can pick up.
Click on plus.
You can see that there are many outputs coming off of this event, which makes it a bit complicated,
but we actually don't need to use most of them.
At first.
Let's just print the other actor.
So again, drag off and create a print string.
And then we can just drag off from other actor and put it into the in string.
However, since the sphere is still blocking, we don't get an overlap event.
We need to change the collision on it first.
We can select the sphere and scroll to the.
Collision Presets section.
As you can see here, it's set to block all dynamic.
If you open this up, you can see the details and you can see that it blocks trace responses and also
blocks world dynamic pawns, pretty much blocks everything.
What we want to do though, is set this to overlap all dynamic.
Our character is a pawn, so we can see that overlap with pawn is checked, which is exactly what we
need.
These collision presets can get very complicated, and it would be too big of a site engine to go into
detail here, but this is all you need to know for now.
Now when we start the game, the character will actually walk through the sphere and we can see BP third
person character being printed on the left side.
So our pick up correctly understands that the character is walking into it.
The first thing you want to do is make this pickup disappear.
So after the print string.
We can simply call destroy actor.
And if we try it out now, we can see that the sphere disappears and the actor as a whole actually disappears
as well.
This great actor is a function that is available on the actor class by default.
With our current setup though, one thing that can happen is that another actor that is not the player
will also destroy this sphere.
To demonstrate this, we can duplicate the sphere.
You can simply drag one more in here.
But you can also hold alt and drag off here to create another instance of it.
So the way we can test this.
To start the game, click on eject and then select one of these spheres and move it into the other one.
And you can see that both of these disappear.
So we need to add a way to check that only the player can can make these disappear and not other objects.
For now, let's delete the print string.
The easiest way we can do this is to drag off of other actor and cast to BP.
Underscore third person character.
And connect the execution pin here to destroy actor.
To display that the cast failed.
We can have a print string here.
And just say not player.
So if it is a player, the actor will be destroyed.
If it's not a player, it will just print, not player.
Let's test this out.
So here we can walk in and it's destroyed.
Nothing is being displayed.
Now we can press shift and F1 to get our mouse back.
Click on eject and drag the sphere in here and you can see it's showing not player.
So now we have a proper way to check for the player, and only then make the sphere disappear.
So this cast checks if the other actor is compatible with the third person character, and then changes
the execution depending on it.
One more thing it does.
It actually gives us access to all of the functions available on the third person character.
For example, we can look for jump here and force the character to jump after picking up the pickup.
Here.
I'm not pressing space.
This is actually just happening through the blueprint.
So I hope this makes you understand how useful casting is.
However, casting also has its downside because it's actually quite computationally heavy and can slow
down your game if you use it too much.
For something like an overlap, it's just fine because it's not happening on every frame or that frequently.
However, you definitely don't want to use this on tick.
Once you get more experienced, instead of using casts, you can actually use interfaces which are very
lightweight.
However, that is a very advanced topic and we're not going to cover it at this point.
So for now, feel free to just use casting everywhere, but make sure to not forget that it actually
has a cost to it.
Instead of jumping, let's try to make the character faster and faster the more pickups they picked
up.
So click on jump and press delete to get rid of this node.
Now we can drag off from the character again and look for the character movement component we talked
about before.
Here we can drag off, and here we can drag off and look for set max walk speed.
This way we can only set a flat value, but we want to get the current max walk speed and add to it.
So drag off again and get max walk speed.
We now want to add a value here, so drag off and input the plus icon.
This will give you the add node.
And here we can just put in a number that we want, for example 500.
And then connect this to the max walk speed.
All this does is get the current max walk speed, add 500 to it and set that as the new speed.
We want to clean this up a little bit though, so we drag this over.
Uh, we can select both of these and press Q to align them.
Move them up.
And then we can double click on this line to create a reroute node and move it over here as well.
Again, we can select both of these by holding Ctrl and then pressing Q to align them.
And let's see if this works out or not.
And as you can see, we get faster and faster the more pickups we collected.
One thing we're doing here that is bad practice is just writing the 500 here, because it can be very
hard to understand what this 500 actually stands for.
This is one instance where variables will come in handy.
A variable is basically a named space in memory that can change the value over time.
And here on the bottom left we can see the variables area in our blueprint.
We can click on plus to add a new one and set a name to it.
In this case speed increase.
There are also different types of variables.
Blueprints are based on C plus plus, so these are strictly typed.
In this case, we want to use a floating point number.
We then need to click on compile.
And here on the bottom right we can see the default value.
We want to set this to 500.
Now you can click on here and drag off into the blueprint.
Then you can pick between Gatsby decrees or set speed increase.
We want to get it.
And now we can just connect this here instead of using the 500 that way.
And this makes it a lot easier to understand what is happening here.
Again.
We can reroute here again to make things cleaner and press Q.
And just to confirm, we can see that everything still works the same way as it did before.
So this part with the variable types can be quite overwhelming and will take some time to get used to.
However, this is not just an Unreal Engine thing, but a general computer science thing, so it definitely
makes sense to learn and understand this over time.
One more great thing about these variables is that we can make these instance editable.
We just have to check here.
And then press on compile.
Now when we go out into the map, we can click our spheres and we can see the speed increase value showing
up here.
And we can change this on a per instance basis.
Now.
So for example we can have both of these at 500.
But we might want only this sphere to add 5000.
So we can easily change this and start test playing right away.
So just like before these add 500 but this one adds 5000.
This is an easy way for us to expose variables so we can change them later easily here, or even have
a game designer come in and only change these values without having to understand code and blueprints.
There are still improvements we can make here.
For example, calling all of this in the pickup is not the best practice, and it would be better to
create a function on top of the character.
So let's do that.
Open up the content drawer and open up the third person character.
In here.
On the left side we see the functions area.
Click on plus to add a function.
We're going to call this increase speed.
And in here we basically want to do the same thing again.
Drag the character movement component in here.
And set max walk speed.
We can also copy and paste this and then get max walk speed and again drag off here and add the plus
icon for the add node.
And in this case we don't want to use 500.
We just want to connect this here.
First connect this as well and clean it up a little bit.
What we want to do here instead is get an input from the function.
So we can click here and increase speed and add an input.
This should be speed, amount and change the type to floating point number.
Now we can simply connect this down here.
But you can see the lines are crossing and it's not very pretty.
We can actually hold control and click here to change where the lines are going.
And move this down and then connect this here, which makes it a lot cleaner.
Now we want to call this function in the pickup so we can get rid of all of this.
And this as well.
And just call increase speed, which we just created.
And here we can again just use our speed increase variable.
And put it in here.
And start test playing.
Yeah, so everything still works the same way, but it's a lot cleaner and better practice.
Of course, there are still many more things we can learn about Blueprint Visual scripting because the
possibilities are basically endless.
However, this is just enough so you can start following along with the other sections of the course,
and you'll learn more and more as we continue.
In the next section, we'll talk about some keyboard shortcuts and some small tips and tricks.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.