WEBVTT

00:00.560 --> 00:02.870
Welcome to your next quest.

00:03.430 --> 00:08.290
Now, in the last quest, our quest was to select our Globes.

00:08.290 --> 00:12.010
But in this quest, our quest is to deselect globes.

00:12.040 --> 00:18.160
Now, yes, we did handle some selection, but I'm talking specifically about deselecting, all passive

00:18.190 --> 00:20.910
globes when selecting an offensive globe.

00:20.920 --> 00:27.280
And then if we're selecting a passive globe deselect all offensive globes, that way, we have both

00:27.280 --> 00:30.160
of our trees working in harmony with each other.

00:30.160 --> 00:33.700
And we'll always only have one globe selected at a time.

00:33.700 --> 00:34.810
So that's our quest.

00:34.810 --> 00:35.740
That's the goal.

00:35.740 --> 00:39.310
So go ahead and pause the video and conquer it now.

00:42.490 --> 00:45.130
Okay, So let's go about this quest.

00:45.160 --> 00:51.850
Now, to reiterate, our goal is to be able to select an offensive spell without having a passive ability

00:51.880 --> 00:57.040
selected and selecting a passive spell will deselect all offensive ones.

00:57.280 --> 01:02.140
Sorry for using spell and ability interchangeably, but I think you get the picture.

01:02.410 --> 01:05.200
We're going to make sure these work together.

01:05.200 --> 01:05.660
Right.

01:05.770 --> 01:14.260
So we can do this using a similar technique that we used to deselect all of our globes in our globe

01:14.260 --> 01:20.200
button by using an event dispatcher on the offensive spell tree only.

01:20.200 --> 01:22.540
We're going to go one level out, right?

01:22.540 --> 01:28.570
We need to go out to the spell menu itself right here in the event graph for the spell menu.

01:28.600 --> 01:31.150
We need to be reacting to it here.

01:31.210 --> 01:34.660
So we're going to go to event construct and it's right here.

01:34.660 --> 01:36.610
We're doing all sorts of things.

01:36.610 --> 01:41.020
We're first binding to onclicked for our close button.

01:41.020 --> 01:43.970
We can also bind to other things here.

01:44.480 --> 01:51.680
So what I want is to bind to something on our offensive and passive spell trees that we can broadcast

01:51.680 --> 01:53.120
when we select something.

01:53.900 --> 02:00.980
So what we can do when we select an offensive icon is broadcast an event dispatcher telling the spell

02:01.010 --> 02:07.100
menu, Hey, we're selecting an offensive icon, so go ahead and deselect all the passive ones.

02:07.710 --> 02:09.120
So let's make a new event.

02:09.120 --> 02:14.970
Dispatcher in offensive spell tree and we'll call this on offensive.

02:15.770 --> 02:18.320
We'll call it spell globe selected.

02:18.980 --> 02:23.510
So on offensive spell globe selected, we don't need to pass anything through.

02:23.540 --> 02:25.100
We just need to call it.

02:25.100 --> 02:32.270
And our passive spell tree can have a dispatcher of its own and this one will be the passive version.

02:32.270 --> 02:35.630
So it'll be on passive spell globe.

02:36.540 --> 02:44.640
Selected and when selecting something will broadcast that one, we'll call on passive spell globe selected

02:44.640 --> 02:47.850
and our spell menu can bind to those.

02:47.850 --> 02:54.780
So it's going to have both the offensive spell tree, which is a variable and the passive spell tree

02:54.780 --> 02:56.130
which is a variable.

02:56.130 --> 02:57.300
We're going to get both of those.

02:57.300 --> 03:00.630
So we're going to get the offensive and the passive.

03:00.630 --> 03:07.260
And for the offensive spell tree, we're going to look for on offensive spell globe selected.

03:07.260 --> 03:09.630
We're going to assign an event to that.

03:11.250 --> 03:18.780
And for the passive we're going to look for on passive spell globe selected and we'll assign an event

03:18.780 --> 03:20.130
for that one as well.

03:20.910 --> 03:26.550
Okay, so what are we going to do when an offensive spell globe has been selected?

03:26.580 --> 03:33.780
Well, we need to deselect all of the passive spell globes so the offensive and passive spell trees

03:33.810 --> 03:35.560
need a deselect.

03:35.580 --> 03:36.660
All right.

03:36.660 --> 03:37.890
So offensive.

03:37.890 --> 03:47.580
We can make a function called deselect all where we just call deselect on all of them so we can get

03:47.580 --> 03:54.990
our first one here and call deselect on it, and then we can get all the others and hook those up as

03:54.990 --> 03:57.150
well so we can time lapse this part.

04:07.090 --> 04:07.970
There we go.

04:07.990 --> 04:13.940
Now, if you wanted to, you could add all of these into an array and use a for loop for that.

04:13.960 --> 04:15.550
I'm just going to do it this way.

04:15.820 --> 04:20.080
Now I'm just going to create a deselect all in the passive spell tree as well.

04:20.110 --> 04:26.140
This would be a good reason for both of them to derive from a parent, but that's okay since it's already

04:26.140 --> 04:32.470
been done, I'm going to go ahead and create a function deselect all and if you used inheritance, you

04:32.470 --> 04:36.130
could use the array and the array would be a bit of a better way.

04:36.130 --> 04:39.610
But we're just going to take all three.

04:40.330 --> 04:41.920
And call Deselect.

04:44.740 --> 04:51.880
So that will be all three of our spell glow buttons and the passive like so.

04:52.000 --> 04:53.650
So we can compile that.

04:53.650 --> 05:00.460
We can compile both of the spell trees and in the spell menu when we select an offensive spell.

05:01.160 --> 05:06.680
We're going to deselect all in the passive, so we're going to call deselect all on the passive spell

05:06.710 --> 05:07.340
tree.

05:07.340 --> 05:13.130
And when we select a passive one, we're going to deselect all in the offensive spell tree.

05:13.130 --> 05:16.640
So we'll take the offensive and call deselect all there.

05:17.770 --> 05:25.360
And with that we should see that we can only select one globe at a time, no matter which spell tree

05:25.360 --> 05:26.230
they're in.

05:27.440 --> 05:28.700
Beautiful.

05:29.560 --> 05:33.610
So that's actually a really good milestone.

05:33.640 --> 05:36.160
Now, there's some tweaking that we could do.

05:36.190 --> 05:44.500
I'm noticing the circle isn't perfectly centered on our passive globes, So, you know, we could kind

05:44.500 --> 05:46.630
of try to perfect that a little bit.

05:46.630 --> 05:53.590
Before we wrap up, I think I'll just tweak that icon a little bit and I'll do so in the animation.

05:53.800 --> 05:54.880
So.

05:56.220 --> 05:58.950
I'm going to just see what it looks like here.

05:59.040 --> 06:05.100
And of course, I'm going to have to take that selection image, set its render opacity to one.

06:05.890 --> 06:11.590
In order to see this and move our animation forward a bit.

06:14.930 --> 06:15.440
Okay.

06:15.440 --> 06:17.930
I think I've found a pretty good, sweet spot.

06:18.260 --> 06:22.320
So I'm pretty happy with how it looks and also how it sounds.

06:22.340 --> 06:24.860
Let's check out how this sounds.

06:34.350 --> 06:36.450
That actually sounds really nice.

06:36.480 --> 06:43.320
Now, remember, we set the render opacity to one, so that's why we kind of see a little bit of white

06:43.350 --> 06:43.920
there.

06:43.950 --> 06:50.040
We have to go back to our spell globe, take that image and set its render opacity back to zero.

06:50.040 --> 06:54.810
And that way we won't be seeing those white sort of artifacts.

06:54.810 --> 06:56.340
So that looks better.

06:56.460 --> 06:57.300
All right.

06:57.300 --> 06:57.960
Excellent.

06:57.960 --> 06:59.160
This is looking great.

06:59.160 --> 07:01.050
And I'll see you in the next video.
