WEBVTT

00:06.880 --> 00:07.990
Welcome back.

00:08.170 --> 00:13.810
Now we're generating a grid of items and we're filtering out items based on whether or not they can

00:13.810 --> 00:16.900
trace to our query context.

00:16.900 --> 00:20.950
And our query context is using aura here.

00:20.980 --> 00:26.620
Now, in this video, we'd like to add an additional test so that we can score these points that have

00:26.620 --> 00:28.300
not been filtered out.

00:28.630 --> 00:32.190
So let's go back to our environment query and add a new test.

00:32.200 --> 00:36.040
I'm going to right click Add test and choose distance.

00:36.340 --> 00:43.330
Now distance allows us to calculate the distance from each point to either the query or which in our

00:43.330 --> 00:47.710
case is the testing pond or some query context.

00:47.740 --> 00:55.330
We can choose to calculate the distance to say, our x player context if we wanted to do that.

00:55.360 --> 00:58.900
Now for test purpose, I'd like to score these.

00:59.050 --> 01:02.200
Notice that our trace was filter only.

01:02.200 --> 01:10.130
So we're filtering points out this occurs first before our distance test is run and this one can score

01:10.130 --> 01:10.580
them.

01:10.580 --> 01:18.970
And what it's going to score is the distance from each point to whatever we set here for distance to

01:18.980 --> 01:25.580
now it's set to querier by default, so it's going to calculate the distance to the testing pond.

01:25.610 --> 01:27.560
Let's take a look at what that looks like.

01:27.570 --> 01:30.050
Notice that we have colors now.

01:30.080 --> 01:32.240
Zero is red.

01:32.270 --> 01:37.790
That's why all of our red nodes, even though they weren't filtered out, they were not scored, they

01:37.790 --> 01:38.780
were only filtered.

01:38.780 --> 01:44.300
So when we filtered out the points that couldn't see aura, they just became blue.

01:44.300 --> 01:49.100
And the rest of the points that we're still dealing with, they still had a score of zero.

01:49.100 --> 01:54.560
But now that we're actually scoring them with our distance test, we're calculating the distance from

01:54.560 --> 02:01.880
each point to the querier, which is the testing pond, and notice that the farthest ones away have

02:01.880 --> 02:02.840
the highest score.

02:02.840 --> 02:05.780
So these are all normalized between 0 and 1.

02:05.780 --> 02:10.700
So this one over here has a high score and this one over here has a high score.

02:10.700 --> 02:17.210
So those are equally considered the best and they're better than all the others that scored less because

02:17.210 --> 02:21.310
they're a smaller distance from the Querier.

02:21.320 --> 02:24.320
What if we wanted the closest one to the Querier?

02:24.320 --> 02:32.600
Well, we could go back to our test and we could use a scoring factor to scale the score of each one.

02:32.600 --> 02:38.030
If we chose negative one, then we're scaling the score by negative one for each of these.

02:38.060 --> 02:44.690
Notice that now the ones that are closer to the querier have a higher score and these two at the corners

02:44.690 --> 02:46.280
have the lowest scores.

02:46.280 --> 02:49.610
They're are the worst scoring of all of the points.

02:49.760 --> 02:52.840
So that's how we can score based on distance.

02:52.850 --> 02:55.750
Now, we don't have to measure the distance to the querier.

02:55.760 --> 03:02.000
We could measure the distance to whatever context we like if we chose our player context and go back

03:02.000 --> 03:02.660
and look.

03:02.660 --> 03:05.690
We'll see that now we're scoring points higher.

03:05.690 --> 03:10.460
If they're closer to aura as that's what our context returns.

03:10.460 --> 03:17.210
And if we go back and change our scoring factor to one again and come back, we'll see that the highest

03:17.210 --> 03:20.350
scoring points are farthest away from aura.

03:20.360 --> 03:25.460
So we're starting to see very quickly how useful these EQs queries can be.

03:25.670 --> 03:33.170
Now, this is going to be used by our Ranger enemies, and I'd like the Ranger enemy to find some point

03:33.200 --> 03:37.760
nearby somewhere in this grid area that can see aura, Right?

03:37.760 --> 03:41.840
So we do want to filter out any points that can't trace to see aura.

03:42.050 --> 03:49.370
But I'd also like that location to be closest to the Querier so our ranger doesn't have to go way far

03:49.370 --> 03:51.920
out before it starts shooting at Aura.

03:51.950 --> 03:58.160
I want it to find the closest point to itself that it can use that can still see aura.

03:58.190 --> 04:04.610
So what I'm going to do is change the distance to to the querier in query context.

04:04.610 --> 04:05.480
Querier.

04:05.570 --> 04:12.260
And I'm going to choose a scoring factor of negative one so that we'll get the points closest to the

04:12.260 --> 04:14.840
querier that can still see aura.

04:14.870 --> 04:20.990
So that means if the Querier is over here behind a wall, then it's going to have to move all the way

04:20.990 --> 04:25.880
up to a corner here and then it can see aura, see how this is going to work.

04:25.880 --> 04:32.180
Now, if Aura was even farther behind a wall like here and I take my querier, I'm going to move it

04:32.180 --> 04:32.860
a little bit.

04:32.870 --> 04:34.940
Notice that none of these points are okay.

04:34.970 --> 04:36.320
They're all filtered out.

04:36.350 --> 04:43.190
We would have to move to one of these points over here to at least be around the corner enough to be

04:43.190 --> 04:45.110
able to shoot at Aura.

04:45.110 --> 04:49.280
So this is going to be the type of query that's going to work for us.

04:49.430 --> 04:53.120
So I'm going to move Aura back over here a bit.

04:53.660 --> 05:01.340
And move my test pawn and I can see that here are the best points, basically the least amount that

05:01.340 --> 05:06.920
our AI would have to travel but still be able to see or around a corner.

05:06.950 --> 05:08.450
It's kind of creepy, isn't it?

05:08.480 --> 05:14.750
So now we have a nice environment query that I would like to run in our behavior tree.

05:14.750 --> 05:18.230
So we're going to use this environment query and we'll do that next.

05:18.260 --> 05:20.930
Great job and I'll see you in the next video.
