Welcome back.
Now we have a slingshot animation blueprint.
And thanks to that, our goblin is holding the pouch.
And that looks pretty great.
But what about when firing the weapon?
Well, when firing the weapon, we're going to want to play a fire montage for that weapon.
And this is specific to the Goblin Slingshot enemy.
So I think what we can do is we can have a Boolean on the Slingshot animation blueprint for whether
or not we should actually be transform modifying the bone and while firing the weapon, we can set that
to false and play that animation montage.
So the way I'm going to handle this is my app.
Slingshot is going to have a Boolean variable, so I'm going to add a variable here.
I'm going to call this holding pouch.
And holding pouch will be true by default.
So I'm going to compile and set it to true.
And in my animation blueprint here, I'm going to blend poses by bool so that if we're holding the pouch,
we should not be using the transform modify bone pose.
We should use just the default idle pose so I can take my slingshot idle.
Animation, drag it out here and use a blend poses by bool.
And simply check holding pouch.
And if holding pouch is true, which it is by default, then we'll use this whole pose that we get from
there.
It doesn't matter if we use the slot or not, because while we're holding the pouch, we're not going
to try playing any montages.
So this will be for the true pose and the slingshot idol will be for the false pose.
And we can go ahead and just hook that up.
Now the question is, when do we change this holding pouch variable?
Well, we can do so based on our Goblin's attack animation.
So I'm going to go into my assets folder, into enemies goblin animations, slingshot, and check out
my attack goblin slingshot montage.
I can place a couple notifies here and in my Goblin Slingshot animation blueprint, I can access my
weapons animation blueprint and set that holding pouch boolean.
And if we really want to see what that slingshot looks like in that left hand, we can go to the weapon
hand socket, we can add a preview asset and search for the slingshot and stick it on there so we can
really kind of see what it looks like.
We're not going to see that pouch on the hand, but that's okay.
So what we want to do is as soon as we release that slingshot right about here, we are going to want
to create an anim notify.
So I'm going to add a new notify track.
This will be for the Rock.
I'm going to call it rock.
I'm going to right click, add a notify, go to skeleton notifies.
And in this asset pack, these two notifies already exist.
Release rock and grab pouch and a new project.
You would say new notify and call it what you want.
But I'm going to use the two that exist here in this asset pack release rock.
And then after releasing the Rock, we go back to about here where we can grab that pouch again.
So right about here, I'm going to add another notify and choose that grab pouch.
Notify.
So these notify just exist already in this project, but you could just create new ones.
It doesn't matter.
Now what we need to do is respond to these in the Goblin Slingshot animation blueprint, and we can
go to that animation blueprint with this icon up here hovering over it, we see a goblin slingshot.
If we click on that now we're in the event graph for this particular Goblin Slingshot character.
Now what I want to do is in the very beginning an event initialize animation, event, blueprint, initialize
animation.
I want to get the pawn owner and I want to access its weapon and from there get its weapons animation
blueprint and then we'll have a reference to that slingshot and MVP.
So we'll do a couple of casts, but this will only happen once here.
What we'll do is we'll take the pawn owner we're going to cast to specifically Goblin Slingshot.
And this is okay, because this animation blueprint is unique to the Slingshot Goblin.
And as the Slingshot goblin, we're going to get its weapon.
So we're going to search for weapon and we need that weapon to be exposed to the event graph.
That means we're going to have to close down.
We'll save all and go into our base character and expose that variable.
So we'll go into character actually in our public folder character or a character base and find the
weapon.
It's in the protected section, it's edit anywhere.
We also need this to be blueprint read only at least.
So making that change, we can compile and launch again.
And back in the editor, we can go back into the animation blueprint for the Goblin Slingshot.
And now that we've exposed the weapon, we can get it.
So get weapon.
And from the weapon we want its animation blueprint to get that we call get anim instance.
Now this returns the anim instance, but we have to cast that in turn to the Slingshot animation blueprint.
So we're going to cast to a slingshot.
That's the weapon animation blueprint.
Once we have that, we can go ahead and promote this to a variable and call it a slingshot.
Now that we have a slingshot, we're in business because now we can respond to those notifies release
rock and grab pouch and set that boolean.
So let's right click and type release rock.
And we're going to get our app Slingshot.
We can make this a validated get by right clicking and converting it.
And from our app Slingshot, we can set that blueprint called, what was it called?
Grabbing Pouch.
Let's see.
We'll go back to App Slingshot.
It's called Holding Pouch.
So we can get the setter for holding pouch.
And if we're releasing the rock, we want to set this to false.
So that's what we're going to do.
We're going to release that pouch.
Now, in the case that this up here failed for whatever reason, if it was called too early before the
Slingshot animation blueprint was valid or whatever reason we could take the is not valid and go through
this whole process again, as in try get pawn owner cast to Goblin Slingshot get its weapon.
This whole thing we could just duplicate down here and hook it up to is not valid.
In that case, that would take care of the not valid case.
But as soon as it's valid, it'll never be not valid again.
So we don't have to worry too much about that.
Now, as soon as we release the pouch, we could play that montage, that animation for our slingshot,
that slingshot attack animation.
We can find that.
It's called Slingshot Attack.
We can browse to it and we can make an animation montage for it.
We can right click create, create an a montage, call it a m, underscore slingshot, underscore attack.
So we have this slingshot attack montage.
We could play that.
We can do that right after setting holding pouch to false.
So what we could do is take the A slingshot that animation blueprint and call montage play.
And we can play that montage.
We can just select it from the dropdown.
Searching for Slingshot.
We have slingshot attack and we can play it there.
Okay.
So that takes care of releasing the rock.
But then when we grab the pouch, we need to handle that case.
So we're going to right click and use our grab pouch and notify and we're going to copy these nodes
and paste them so that we can set holding pouch to true.
Again, I'm not concerned with the not valid case because by this time we know that we've released the
Rock first.
So by the time we hit Grab Pouch, it's definitely valid, that animation blueprint variable.
So now if our goblins attack happens, we know that it's going to get that animation blueprint for the
slingshot.
It's going to set that holding pouch boolean and it's going to play the montage for it.
So we should be able to see all that when our goblin attacks when it shoots at us.
And it's a little hard to see, but I can definitely see it.
We can, of course, zoom in a bit.
We can even go to another map so that we only have just a goblin slingshot here.
And that will allow us to see a little better.
And why don't we just really quick go to our blueprints character.
Ora ora character.
We can bring in that spring arm a bit.
It's at 800.
We're going to bring it in to about four.
360 or so.
And.
Let's see if we can get a better look.
And there's that slingshot attacking.
Look at that stretch.
That looks great.
I know.
It just killed Aura and it's still firing.
That's something we have to deal with.
But look at that.
That is looking nice.
We can even eject and kind of zoom in and just admire how this looks.
This is really pretty cool.
And this concept can be used for bow and arrow characters for crossbows, really anything that requires
movement on that weapon.
So that is super cool.
Now, back here in the other level, let's just make sure things are looking good over here, make sure
there isn't anything too crazy.
One thing I'm noticing and I don't know if I can repro it here, is that the rocks are blocking the
camera channel.
In fact, I don't think the rocks should block anything.
We have our overlap events for things like that.
So I'm just going to go to the Slingshot rock.
And I might have to go into blueprints, ability system, enemy abilities and slingshot rock.
And I'm going to take the rock mesh and disable collision on it.
I don't want it interacting with anything.
So I'm going to set it to no collision.
And the sphere itself should already be ignoring camera and visibility and the sphere could be a little
bit smaller, I think.
But again, we don't want too much precision in a top down.
We can have a little bit of leeway when it comes to these collision volumes as everything will be zoomed
out.
Right.
Aura is not always going to be with the spring arm length of 360, it's more likely going to be 800.
Unless, of course, we make that something you could change in game, but this is more likely.
And so for that reason we don't really want a really small sphere for those projectiles.
All right.
And one last thing that I'm noticing is my slingshot goblins are actually sliding now.
I don't see them running and that means I broke something.
So let's go into the animation blueprint and notice that we're depending on some things happening in
the Parent Blueprint event.
Update Animation is calling the parent version, but now we're using initialize animation that's not
calling the parent version.
So we're going to have to right click and add a call to the parent function and let's make sure that
we're calling that so that everything is initialized on the parent as well.
So now if we press play, now they're running with their tiny little cute legs and everything's looking
great.
Excellent.
See you in the next video.