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 video, we're just going to create a simple flying enemy that just flies between point A and
point B, and this is going to be the BP enemy bat which has a fly patrol system.
And again, it's based on the enemy base which is based on the action chart base.
First, we can just clean this up again and close all the tabs and open the content drawer.
Go to blueprints, characters, enemies, and on the BP enemy base, right click and create Child Blueprint
class and call BP underscore enemy.
Underscore.
Bat.
Again the first thing in here we just open it up and we set the sprite to look for bat.
And the bat only has an idle animation.
Nothing else.
We don't have to worry about setting up paper XDD.
We also don't have to worry about switching animations in paper 2D as well.
Now first we can just put this into the map.
So just open up the map and just drag out the BP enemy bat.
And again we want to make sure that it's on the same lane.
So put the y two -50.
And we can just drag it up in the air.
And also rotate it around like here at 180 on the Z to have it look to the left side.
Towards the player.
And yeah.
So now if we go to simulate.
You can see that it just falls down.
Because of course, we have to tell Unreal Engine that we want this character to fly.
And this is actually very easy.
So in the bpn we bet on the character movement component.
We can just look for movement mode, which is a setting on here.
And we can just set the default land movement mode to flying.
And now I just compile and save and I check it out again.
And hey, this already solved the problem.
The bat is now not falling down anymore.
It's ignoring gravity and it is flying.
And now we just want to make the bed move between point A and point B, and for this, we actually don't
even need an AI controller.
We can just do this right in the blueprint because it's that simple.
And it doesn't really fit the pattern of the brain telling the body to do something.
Back in the enemy bat.
We now click on the capsule component and we just want to add a scene component again.
And the scene again.
It's just a very simple object that can have a position, a rotation and so on.
And we're just going to call this one top pose like this.
And we can click out of this.
And again we want to make sure to just attach a billboard here.
And this just makes it easier to see.
Right.
And then we can select this top pose and zoom out a little bit and just drag this up here.
And then in the end the bat is going to try to fly towards this position.
And we actually want to have a second position.
So here we can just duplicate.
And it's called bottom pass.
And for this one we also want to add a billboard.
Like this.
And drag it down, but now the billboard is actually in a weird position.
So we can go to the Billboard one and just click here to reset.
And then you have the bottom pass.
And again we can adjust this in the map.
But for now it should just have a little bit of a range here.
And now I just want you to think for a second.
How do you think we're going to be able to achieve this?
There's a couple of different methods, but I want to go for the simplest one.
And if your answer was timeline, then you are correct.
And we've used timelines before for a couple of things.
And this is just another instance where we use timelines.
So on the event graph, we can just right click here.
Make a custom event.
And just call it move.
And from this we want to make a new timeline.
So just add timeline and just call it move anim.
Like this.
And we want to not use play, but hold control and use play from start.
And this way you can just make sure it always starts from zero.
And on update.
We then want to set actor location so we're not going to use physics.
We are forcefully setting where the bat is going to be, and we're going to update this on every tick
when this timeline is active.
So how do we get the location now though?
Again, we can use the timeline to give us a value between 0 and 1, and we can then use a lerp vector.
Which is going to use this alpha and show either the A value or the B value, or something in between.
And for the A value, well, we can just use our top pass.
And here just get world location like this.
And for the bottom bus the same thing.
Get world location and just put this in here.
There is going to be a small bug with this method, which we're going to talk about, but for now,
this is the way you would go about this most of the time.
And now let's just worry about the alpha.
So just double click this here.
And again I always like to set a length of one and then change this later with the play rate.
Just click on Plus Track and add a float track because we just want a number and just call it Alpha.
Again right click here.
Add a key start at zero.
Time and also start at zero value and then add another key.
Go at time one and value one.
And we want to make this a little bit smoother.
So just select both of them with left click right click one of them and go to auto.
So we get this ease in and ease out here, which is just going to make it look more natural.
Now back in the event graph right.
We get this alpha.
We can just put it in here.
And just go like this.
Double click.
And we still need to call this timeline.
And for now we just want to play it once.
So for now, this is fine.
We just want to call the move on begin play.
So let's call move.
Like this.
And if I click on stimulate now we can look at the problem and you can see that the character just zaps
around like crazy.
And the reason this happens is that on the enemy bat, the top position and bottom position are actually
attached to the capsule component, so they will move together with the character.
So the character is trying to follow this position, but the position moves with the character.
So this is kind of the problem of having a carrot on a stick.
And the carrot just moves with you and you keep on chasing the carrot, and then it just goes all over
the place.
Just going to the top position and setting the transform to world also doesn't work, because we have
the absolute location, and it's going to try to go into the map, then into a different position,
because then it's going to find this position in the world.
So this also doesn't work.
Just set this back to relative.
So we have to use a little bit of a different approach.
We now simply want to save the initial position of the top pose and bottom pass.
And we're going to use that as a reference.
So then we don't care if the position is actually dynamically move with the character.
So in the event graph before we use the move function, we just want to get the top pass here get world
location.
And we can then just promote this to a variable.
And just call it World Top Plus.
And save this here in the variable.
And then do the same thing for the bottom canister.
Drag off here.
Get world location.
And promote the variable world bottom pos.
Like this.
And after this we want to call the move.
And now we need to use these variables here instead of the dynamic ones.
So we can just get rid of these and just drag in the world top bars and drag in the world bottom pass.
And so this basically just uses the position we set.
In begin play and we just save it, and then we don't really care if this changes later on because we
already saved it.
And we're just going to use the saved variable for this.
So let's check this out.
Now I go here simulate.
And you can see that we make a full loop from top to bottom.
So this is working out fine.
Of course, you also want to go back up again and keep on looping this.
And one thing we can do is to just create another custom event.
So here custom event.
And it's called Move Forward.
This and play from start and after we are finished we can just call move forward for example.
And now it's just going to keep on looping like this.
And this is still not a perfect.
But this just shows you how we can use multiple custom events.
But we actually also want to have a move backward.
So here we can have a custom event.
And going to call it move backward.
And this we use reverse from.
And so here we play from the end again.
And this regular move custom event we can just get rid of now.
And we just use the move forward move backward.
So now at the top we actually have to call not move but move forward instead.
And we just change the name basically.
And one problem we have now is that we actually don't know after finished did we just finish the move
forward or did we finish the move backward.
But we know it's always going to alternate.
So here we can simply use a flip flop.
And flip flop is a flow control node that is going to play A on the first time, and the second time
it's going to play B.
So the first time we know we start from move forward, we want to move backward.
So here we can just move backward like this.
And we got to open up some more space here.
This and yeah.
So first time move backward.
Second time move forward.
Like this.
And yeah, this is it.
So first time we go here we play it again.
And then we played from this.
And we just keep on looping back and forth and back and forth.
All without having to use the tick event.
Let's try it out.
So we go up and down and up and down.
And you can see the smoothing at the top and bottom where it becomes a little bit slower.
And this is because we implemented it that way in our timeline.
One improvement we can make to this is that actually right now we don't have control over how fast this
is playing.
So we can go to the enemy bat.
And for the move anim we can actually set the play rate.
So we can just get the mov anim.
Type it in.
Getmove enum and set the play rate.
Like this.
And again, if we set it to two, it's going to be twice as fast.
If we set it 0.5, it's going to be half as fast.
And we just want to promote this to a variable and just called move play rate.
And compile and save.
And let's just have a value of 0.8 as the default.
And compile and save.
And now we actually want to call this before the move forward.
On begin play.
Right.
We call this once.
And let's just try this out now.
And you can see the movement is a little bit slower, and we can actually also go through the move play
rate and make it instance editable.
So we can compile and save now and let's just copy this bat hold alt and drag off here.
And we can say that, well, this bat is supposed to be slower.
So here, if it's selected, we can go here to the right.
And under default we see the move play rate.
And let's say this one is just 0.4 for example.
Right.
And you can see the difference.
And now not only the programmer but if you have a game designer or a level designer, they could come
in here and just set a different speed for all of your different enemies.
And not just that, if we select this bat, we can also go here to details and we can see the top pass
and the bottom pass.
And we can change this on a per instance basis.
Right.
So we could have the top pass here.
Have the bottom pass here and we can kind of make the bat go diagonal.
And this is again a very cool tool for level design, and it just brings some variety with it.
In the next lesson, we'll create the last basic enemy type.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.