Welcome back.
So now that we've associated our montages with gameplay tags, we now want to get the correct socket
location because some of our characters have weapons, others don't.
And our goal, for example, is going to have two sockets, one on the left hand, one on the right,
and each montage is associated with that given socket.
So what we need is a way to use a tag identifying a socket and retrieving that tag.
So get combat socket location needs to take a gameplay tag now.
So we're going to do that in this video.
So first we go to the combat interface to our get combat socket location and we change it.
So it's going to now have a const gameplay tag and we'll pass that in by reference.
We're going to call this montage tag.
Now that means we need to change it everywhere.
We're using it where implementing this in Aura character base, which means we have to find get combat
socket location here and change that, make sure it takes that input parameter.
And we also have to change the definition here.
Now we're checking the weapon and we know that that's not going to fly for our ghoul, is it?
Our ghoul doesn't have a weapon, so that check would fail.
We're going to remove that right away.
And here we need to actually return the socket based on this montage tag.
So that's something we're going to have to do.
Let's do a to do here that says return correct socket based on montage tag.
Now we're also using get combat socket location in aura, a projectile spell.
So we need to go into ability system abilities into aura projectile spell where we're calling get combat
socket location the execute version.
Now that this has a input parameter that's going to be the second input.
So we need to pass one of those in and that needs to be a gameplay tag.
So what we can do is use F or a gameplay tags get.
Dot and we can get montage attack weapon.
That's the gameplay tag that we'd like to associate with the weapon.
But of course get combat socket location needs to do the right thing based on that tag, doesn't it?
So we only have three options weapon left hand and right hand.
So I think I can just check those three cases here.
Now, you may not like that solution.
You may wish for this to be something that doesn't have to change.
If we expand the number of sockets possible for all of our enemies and so on in this project, I know
that I only have enemies that either have weapons or a left and a right hand, so I'm okay with just
checking these three, but if you really wanted, you could make this a little more data driven.
You could make a team map mapping montage tags to names for the socket location and make this an algorithm
that will look up that team map.
So just so you know, you could do it that way.
You could make this a little bit less hardcoded.
But in this case, I'm okay with just having three cases.
I don't foresee any additions to this for any different types of enemies.
So what I'm going to do is literally check the montage tag and return the socket based on that.
So I'm going to say if montage tag dot matches tag exact and f or a gameplay tags get dot montage attack
weapon.
Now I could just store a local F or a gameplay tags.
We could make this a const reference called gameplay tags and use f or a gameplay tags get so we don't
have to type so much each time, but if this is the case, then I'm going to return the socket on the
weapon.
So I'm going to cut that and paste it here and I'm also going to make sure the weapon is valid.
So I'm going to have an and is valid and check the weapon.
I can replace the call to get with gameplay tags here.
Now I'm also going to check for the other two types of montage tags.
So I'm going to paste this twice.
The next one is going to be Montage attack left hand and I'm not going to check is valid for the weapon.
We're going to use the mesh on the character for this.
So we're going to return instead of weapon, we're going to call, get mesh and get socket location
and we actually need a socket name for the left and right hands.
So we'll go ahead and add those to our character base along with weapon type socket name.
We'll have two more that will set from the blueprint.
So instead of weapon tip, this will say left hand and instead of weapon tip, this one will say right
hand.
And that's what we'll use here in this function.
We're going to get mesh, get socket location.
This is for the left hand.
So we're going to say left hand socket name and the next one is checking against montage attack right
hand.
We're not going to check as valid weapon and we're going to use get mesh instead of the weapon, get
socket location passing in right hand socket name.
So now get combat socket location will return the correct thing.
Now before we compile and launch, we just need to make sure all paths return a value, which means
by the end of this function, if we haven't returned yet, we can return an empty f vector.
So the last thing to do is compile and we can go back into the editor and fix up our blueprint where
we're calling this.
So opening our gameplay ability.
Melee attack.
Now we can pass in a montage tag into jet combat socket location.
Now that's going to be the tag we're waiting for.
So we're going to get it from this break tagged montage here.
That's what we're passing in.
So we'll go ahead and pass that in compile.
And now this should work.
As we're getting that tag from using our combat interface and our Goblin Spear.
If we search for its attack montages.
We see that it's using a montage attack weapon.
So really we're never going to use the tag we were using before, which was event, montage, attack,
melee.
We can actually remove that melee tag.
We're not going to use that anymore.
We are still using event montage firebolt, So we'll leave that one.
Okay.
Let's save all and test.
See if we still take damage, if we're still getting that montage being played.
Everything still works perfect.
Now, this is great because now our melee attack can be used on characters that use an attack montage
and really any of the three sockets, whether it has a weapon or it's using sockets on its hands.
So that means we're going to go to our ghoul static mesh and go to his hands and add sockets to it so
that we can use those.
Now the hand is kind of the forearm bone, so I'm going to get the wrist bone, which is a little farther.
And this is wrist L I'm going to right click and add a socket and rename this socket to left hand socket
and I'm going to go to wrist are add a socket and call this one right hand socket and just make sure
that these are at a good location.
I'll move them out on the hands just a bit.
Like so.
And when we make a Goole blueprint, we're going to make sure to set those socket names.
And our goblin spear should have its weapon type socket name set to type socket.
And it does.
If I just search for combat, I see all three of them and I don't need to set left hand socket name
or right hand because we're only using the weapon.
All right.
We're one step closer.
We're almost ready to start making a ghoul blueprint, and the ghoul is going to get to use the melee
attack and it's going to have its own attack montages using the left and the right hands.
Excellent job.
And I'll see you in the next video.