Okay.
Welcome back.
Now, there's an interesting problem, and you don't know about it until you've unlocked another ability,
spent a point on it and then tried to equip it.
You'll see that it clears out anything else that's there.
Now, that's a pretty easy fix and it all comes down to our equipped row button.
You see if the ability tag is none, then we clear the globe.
But we shouldn't do that unless the input tag matches.
So right here we're checking.
If we match the input tag, we should actually check if we match the input tag first.
Otherwise, we're just going to clear every single one of our globes every time.
So we'll have this branch here.
And we'll hook the false up to the rest of what it's doing and the true up to clear globe.
And that's the true for if it's ability is none so that should fix that.
And after that our spell menu should be working.
Let's level up.
Let's upgrade this ability.
Let's equip it to right mouse button.
And there we go.
Now, this is awesome because now I can right click to electrocute.
I can left click.
Of course, with shift.
Our left mouse button requires the shift unless we have a target.
Right.
But we can now take the electrocute ability, press, equip and click on the left mouse button slot
and push that firebolt ability out.
And now it's our left mouse button that does our electrocute and we can take our firebolt and equip
it to the right mouse button and we can really use any of these that we want.
Doesn't matter.
We now have inputs that can be reassigned via the spell menu.
This is actually a pretty big deal and it's something that I've been requested a lot to cover, and
this is just one way to do it.
It's not really a input remapping, extensive system.
It's just for our spell system.
We now have the ability to remap our spells to different inputs and it looks great.
And we can cancel.
And it's pretty robust.
So now our spell menu is actually pretty much complete.
The only thing is when we add new spells, we need to give them descriptions, but other than that,
the spell menu is pretty much done.
We just need to make sure to update our overlay.
Now that's pretty easy because there's a delegate broadcast by the ability system component and that's
what we respond to, to update this right here so we can do the same thing in the overlay.
So what is that?
Delegate It's on ability equipped.
So this is what we're doing.
We need to do the same thing in the overlay widget controller.
So we're going to have an on ability equipped in that class.
So I'm going to go ahead and just close out of all the other tabs except for spell menu, widget controller,
CP, and I'm going to go into my overlay widget controller and make a callback here to bind to that
same delegate and I'm going to give it the same name on ability equipped.
I can just copy the signature.
And an overlay widget controller.
I'll just make it a protected function.
Void on ability equipped.
And let's generate a definition.
Now we need to bind this so we'll get our ability system component.
We're going to want to cast it to aura, ability, system component.
And the first thing I'll do is I'll call, get or ask.
And get our ability equipped delegate.
We're going to add you object with this comma at you overlay widget controller on ability equipped and
there we go.
Now we just need to handle an ability equipped.
I'm going to take my spell menu, widget controller function, copy the whole thing, and then we'll
paste it over and change what we need.
We don't need this line.
We don't have that boolean here.
We do want gameplay tag, so I'm going to include for gameplay tags.
We do want to broadcast last slot info, so we'll broadcast abilities none for that at the previous
slot.
And we also want to get ability info for the current tag and broadcast it at its current slot.
And then we don't need to broadcast this other delegate that was specific to the widget controller for
the spell menu.
So these are the only things we need to do.
This can also be a const function.
So we'll make it const and let's just make sure we're handling this properly in the editor.
So I'm going to close the editor.
Save, selected and relaunch and just see how things work now that we're calling on Ability Equipped.
All right.
We're back in the editor.
Let's press play.
Let's change our spell situation.
And so we got that same white square problem.
Now that we know how to fix it, we can fix it pretty easily.
We have to go to our overlay though, and actually it's not even the overlay.
It's in UI overlay, sub widget health, mana spells, and it's in each of these.
So these are spell globes.
Spell globes.
Let's open that widget class.
So UI spell globes and it's actually the spell globe class.
Let's see what we're doing here.
We're receiving ability info and right here we can check.
If we match the input tag, then we can also check with another branch.
Right here and only false will continue.
And what are we checking?
We're checking the ability tag.
We're seeing if it matches tag exact abilities.
None.
If it does match tag exact abilities?
None.
Then we want to clear the globe.
Let's call Clear Globe.
And just looking at Clear Globe, Yes.
Sets it to a transparent background.
So with that.
We should have things working.
And we do.
And we'll go ahead and level up.
I have to right click now.
Boom leveled up.
Let's upgrade that ability and equip it to.
Uh oh.
Something happened that I didn't quite see.
Let's see what happens.
How can I repro what just happened?
I think I have to put this there and then upgrade inability by Oh, I see a couple of problems.
Okay.
So as soon as I switch to the right mouse button and I fired off, I saw that my cooldown is actually
what's messing things up.
So it appears to be related to the cooldown.
And if we go back to our spell globe.
We'll see that.
We're listening for a cooldown change for the cooldown tag, which once this spell globe has been cleared
out, we should clear out its cooldown tag as well.
So let's go back to receive ability info.
And here, if the ability is matching the input tag for the slot and its abilities, none.
We should set the cooldown tag to an empty tag and that should make sure that it no longer listens to
that old cooldown.
So what I did to repro the issue was equip firebolt to right mouse button and then level up.
Then upgrade, electrocute and equip it to left mouse button and then fire the right mouse button ability.
And we did see that before.
The reason that it put the white texture on the left mouse button slot was because it was still listening
to the same cooldown tag.
So now we've fixed that.
Okay.
And now we can equip things as we see fit.
We can unselect things.
Things look great.
So one last polishing touch that I think I'd like to do is as soon as we've assigned an ability to a
slot, I'd like to deselect what I previously had selected.
I don't want to have to go up there and click it and unselect it.
And also I'd like to play a sound when we equip something.
I think that's also something we could do.
So a couple of polishing last steps and we'll do those in the next video.
Excellent job and I'll see you soon.