Welcome to your next quest.
Now, in the last quest, our quest was to select our Globes.
But in this quest, our quest is to deselect globes.
Now, yes, we did handle some selection, but I'm talking specifically about deselecting, all passive
globes when selecting an offensive globe.
And then if we're selecting a passive globe deselect all offensive globes, that way, we have both
of our trees working in harmony with each other.
And we'll always only have one globe selected at a time.
So that's our quest.
That's the goal.
So go ahead and pause the video and conquer it now.
Okay, So let's go about this quest.
Now, to reiterate, our goal is to be able to select an offensive spell without having a passive ability
selected and selecting a passive spell will deselect all offensive ones.
Sorry for using spell and ability interchangeably, but I think you get the picture.
We're going to make sure these work together.
Right.
So we can do this using a similar technique that we used to deselect all of our globes in our globe
button by using an event dispatcher on the offensive spell tree only.
We're going to go one level out, right?
We need to go out to the spell menu itself right here in the event graph for the spell menu.
We need to be reacting to it here.
So we're going to go to event construct and it's right here.
We're doing all sorts of things.
We're first binding to onclicked for our close button.
We can also bind to other things here.
So what I want is to bind to something on our offensive and passive spell trees that we can broadcast
when we select something.
So what we can do when we select an offensive icon is broadcast an event dispatcher telling the spell
menu, Hey, we're selecting an offensive icon, so go ahead and deselect all the passive ones.
So let's make a new event.
Dispatcher in offensive spell tree and we'll call this on offensive.
We'll call it spell globe selected.
So on offensive spell globe selected, we don't need to pass anything through.
We just need to call it.
And our passive spell tree can have a dispatcher of its own and this one will be the passive version.
So it'll be on passive spell globe.
Selected and when selecting something will broadcast that one, we'll call on passive spell globe selected
and our spell menu can bind to those.
So it's going to have both the offensive spell tree, which is a variable and the passive spell tree
which is a variable.
We're going to get both of those.
So we're going to get the offensive and the passive.
And for the offensive spell tree, we're going to look for on offensive spell globe selected.
We're going to assign an event to that.
And for the passive we're going to look for on passive spell globe selected and we'll assign an event
for that one as well.
Okay, so what are we going to do when an offensive spell globe has been selected?
Well, we need to deselect all of the passive spell globes so the offensive and passive spell trees
need a deselect.
All right.
So offensive.
We can make a function called deselect all where we just call deselect on all of them so we can get
our first one here and call deselect on it, and then we can get all the others and hook those up as
well so we can time lapse this part.
There we go.
Now, if you wanted to, you could add all of these into an array and use a for loop for that.
I'm just going to do it this way.
Now I'm just going to create a deselect all in the passive spell tree as well.
This would be a good reason for both of them to derive from a parent, but that's okay since it's already
been done, I'm going to go ahead and create a function deselect all and if you used inheritance, you
could use the array and the array would be a bit of a better way.
But we're just going to take all three.
And call Deselect.
So that will be all three of our spell glow buttons and the passive like so.
So we can compile that.
We can compile both of the spell trees and in the spell menu when we select an offensive spell.
We're going to deselect all in the passive, so we're going to call deselect all on the passive spell
tree.
And when we select a passive one, we're going to deselect all in the offensive spell tree.
So we'll take the offensive and call deselect all there.
And with that we should see that we can only select one globe at a time, no matter which spell tree
they're in.
Beautiful.
So that's actually a really good milestone.
Now, there's some tweaking that we could do.
I'm noticing the circle isn't perfectly centered on our passive globes, So, you know, we could kind
of try to perfect that a little bit.
Before we wrap up, I think I'll just tweak that icon a little bit and I'll do so in the animation.
So.
I'm going to just see what it looks like here.
And of course, I'm going to have to take that selection image, set its render opacity to one.
In order to see this and move our animation forward a bit.
Okay.
I think I've found a pretty good, sweet spot.
So I'm pretty happy with how it looks and also how it sounds.
Let's check out how this sounds.
That actually sounds really nice.
Now, remember, we set the render opacity to one, so that's why we kind of see a little bit of white
there.
We have to go back to our spell globe, take that image and set its render opacity back to zero.
And that way we won't be seeing those white sort of artifacts.
So that looks better.
All right.
Excellent.
This is looking great.
And I'll see you in the next video.