alright welcome back in the previous
video we got our characters gun attached
properly to his hand so he's all
animated and looking good and now we
want to animate the enemy character now
here's a quick spoiler this is going to
be a very very quick and easy process
because we're going to reuse some of the
work we've already done we could create
a brand new blend space for our care for
enemy character a brand new enemy and
blueprints specifically for him and we
could assign that exactly the way we did
with the hero what we're going to do
instead is we are going to make a new
blend space to drive between walking and
standing at idle but for our for our
enemy we're just going to reuse the
existing animation blueprint that we all
recruit already used on the hero which
is why we named it character animation
blueprint and not hero animation
blueprint so let's go over to our
animation assets folder and the first
thing we want is to create our blend
space now our enemy character is always
going to turn toward the player he's
always rotated such that he's basically
moving forward and we can see that here
no matter what's going on these guys are
always rotating toward the player so we
don't have to worry about direction
what that means is in terms of a blend
space if you right click and go to
create another blendspace there is a
blend space 1d that we could create
which would be just fine because all we
need is speed however we're not going to
use that and you'll see why here in just
a moment for now just go with me
so we'll create a brand new blend space
and it's going to get just a regular one
not a 1d but a regular blendspace we're
going to base that off of the ue4
mannequin skeleton just as we did before
and we'll call this the enemy blendspace
or enemy blend
fine and light control s and open this
up now this is still going to have the
gun attached to it remember that's just
a preview asset so at any point you can
right-click on the gun socket and choose
remove all attached assets so that takes
away all those preview assets it's still
going to be attached to the game because
we did that in blueprint but it just
gives you that preview
ok so now let's set up the parameters
for this blend space
first off we have our x axis label we
might as well go ahead and set out the
same way so let's call it direction
let's get the same range of negative 180
positive 180 let's give it a y axis
label of speed and we're going to give
this a slightly different ranges will go
between 0 and actually 100 will probably
be just fine
that'll be okay because once we make it
up to 100 centimeters per second above
we wanted to look like he's walking so
that should be alright so let's go ahead
and apply those changes always super
important to do that but the blend space
itself is going to be really different
because we only have two animations we
have idle and we have walk and all we
really care about his speed so we could
if you wanted to you could drag idol to
the center of the graph and if it helps
make things a little clearer by all
means go ahead and do that let's go
ahead and drag an idol at the very
bottom and then a walk at the very top
but no matter what direction the
character thinks it's it's going we want
to always just be walking so we're going
to put walk in the upper corners both
the upper corners what and he's not
walking
and that's because we are not playing so
if we hit play then things seem to work
better and yes again we know this
animation has a little bit of a pop to
it that's okay it's just a temporary
animation anyway
now let's take enemy idol and we're
going to put that down in the lower
corners just for consistency we don't
really need to do that but now we can
test it no matter what direction we are
moving we're always going to look like
we're rotating forward that's fine for
this character because he's always just
going to be moving forward so we can
save this and if at this point you're
thinking in the back your head
why didn't we just use a blend space one
deep
now i'm going to explain it to you we
can now take our character and MBP that
we created earlier right-click on it and
choose create child blueprint class so
this will descend or inherit from
character n MVP and have all of the same
properties all of the same animations
we're going to call it enemy and MVP to
control s and then we'll double-click to
open this up and take a look here we
have the asset override editor open by
default so now we can override animation
assets within this animation blueprint
so let's do that let's expand locomotion
and there is our blend space right there
so it's using the hero blend well
because we made a two-dimensional blend
space for the enemy
it's the same type of blend space so now
it's completely compatible with what we
had here so now check it out
we can just choose the enemy blend
recompile and now we're done
that's it we've already set up the
enemy's animation blueprint we can
change the speed and is it makes it to a
hundred he goes into a walk that's it
that's all we needed to do so compile
save close we can go over to our enemy
characters let's go under blueprints and
let's open up the enemy character will
select his mesh and then under that
NM blueprint generated class property
right here we can set this to the enemy
and MBP compile and save and now if we
play
we're already done they're already
walking there actually walking a little
too quick as you can see their feet
sliding so we'll probably want to slow
them down just a little bit or we could
speed up the walk a little as well in
fact let's do that let's go into let's
escape
let's open up our animation blueprint
let's go actually let's go in her
animation assets and let's find enemy
walk right here and if we take a look
there's a rate scale so we can push this
up to say like 10 1.5 that's too fast
let's do like 1.2 that really makes that
popularly present but again that's okay
this is just for for demo purposes so
now if we play there you go now they're
walking just a little bit faster if you
don't really sliding as much and they
really had this kind of dedicated march
but you see in this way it was very easy
for us to reuse some of our existing
work now also I this video is like
super-short we're technically already
done but I'm gonna do something really
quick because it's been driving me crazy
for the last few videos and I've just
been ignoring it but i'm going to take
the enemy color and change it slightly
it's just a little bit too / driven so
we're going to desaturate that by just a
bit and compile and another pink and
only me
it's pretty funny for them to be pink
you know what I'm going to change their
color entire let's make this let's make
the bad guys
orange orange is a great color
there we are
pick just the right color there we go
this is kind of what I was looking for
right it's just a little bit more of a
desaturation read something it wasn't
quite so brutal on the eyes in our scene
so something kinda like that and compile
and save and if we play there we go
cool so we've now animated both our hero
and our enemy
however there is one last thing you
notice our enemies are just plinking out
of existence so we need to set up the
same behavior that we set up on on our
hero and give them a little bit more
time to play a death animation i
actually forgot to do that well I guess
if the videos / haven't forgotten you
have I so let's go into our event graph
for our enemy character and right here
after is dead we can do the same thing
we did before we can do a delay of three
seconds and this is gonna be kind of
funny so I'm going to show you what
happens if you just play this watch
so if we kill an enemy look at this he
falls down and he keeps chasing us for
like three seconds until he's destroyed
they just keep sliding after us and
that's because technically they're still
chasing us down so let's fix that
there's a special node in order to do
this and it is called detach from
controller pending destroy so what this
does the name is really verbose right
this will detach our enemy character
from it's AI controller knowing that
we're going to be destroying it here in
just a moment
so then the AI controller will no longer
be telling the enemy to chase us
so what we should see is the character
just falls down which is great that's
exactly what we want now there's still a
problem here but it's a really subtle
problem you have to play a lot to test
it out and to make it a little easier to
show off i'm going to grab my spawn
volume real quick
until it's only spawn one enemy at a
time
so should only have the one if I kill
him i still get hung up on him i don't
know if you can really feel that in the
video but there's still a collision
surface there so I knocked him down and
try to run into him and I'm a bumping
into something right there so let's do
this let's say that as soon as the enemy
character dies
we're going to change his capsule
components collision so let's drag this
out drag a reference out to it and then
let's drag a wire off this and just say
collision and see what we have
well we're going to change the response
to a channel so the way collisions work
we actually take a look at the capsule
component and look under collision we
have all kinds of different channels we
can set up we can say I like if i expand
collision presets we can say in response
to static objects we want to overlap or
block or doing overlapping block pause
etc and so forth
we're going to a couple of things here
we are going to dynamically change the
collision behavior the moment the enemy
dies so let's take the its response to
world dynamic which will be things like
our lasers and have it ignore those and
then let's let's do another reference or
we could just do another reference or we
could I do like a rear out node it's
what it's the same thing whichever way
you want to go and let's set collision
and do a set collision response to
channel once again running to the same
thing twice and this time we're going to
take all of our responses to pawns like
the player and set that to ignore as
well so we should no longer be hitting
lasers we should no longer be hitting
the player will clean that up with some
rewrites but when is this going to
happen
well let's have this happen right before
we detach from the controller which will
seem pretty instantaneous between the
two
we'll plug that in and plug that in and
let's clean up our graph a little bit
will have everything going in a nice
clean straight line and there we go so
let's compile save and play and so now
we can shoot our enemy and run right
through it
that's also going to be really useful
where if we get these guys grouped up
our lasers won't stop on that collision
we can start shooting whatever enemy was
right behind him
awesome so the video net did end up
going a little bit longer than i thought
but now we've got our enemies animating
we've got our collision set up properly
when they die really honestly at this
point the game as far as just saying a
pro pro typing something out and getting
it playable the game is essentially done
but we are going to do one last thing to
really finalize it and we're going to
create a UI for a very simple UI using
umg which is what will tackle in the
next video so thanks very much for
joining us