Welcome back.
Now we're generating a grid of items and we're filtering out items based on whether or not they can
trace to our query context.
And our query context is using aura here.
Now, in this video, we'd like to add an additional test so that we can score these points that have
not been filtered out.
So let's go back to our environment query and add a new test.
I'm going to right click Add test and choose distance.
Now distance allows us to calculate the distance from each point to either the query or which in our
case is the testing pond or some query context.
We can choose to calculate the distance to say, our x player context if we wanted to do that.
Now for test purpose, I'd like to score these.
Notice that our trace was filter only.
So we're filtering points out this occurs first before our distance test is run and this one can score
them.
And what it's going to score is the distance from each point to whatever we set here for distance to
now it's set to querier by default, so it's going to calculate the distance to the testing pond.
Let's take a look at what that looks like.
Notice that we have colors now.
Zero is red.
That's why all of our red nodes, even though they weren't filtered out, they were not scored, they
were only filtered.
So when we filtered out the points that couldn't see aura, they just became blue.
And the rest of the points that we're still dealing with, they still had a score of zero.
But now that we're actually scoring them with our distance test, we're calculating the distance from
each point to the querier, which is the testing pond, and notice that the farthest ones away have
the highest score.
So these are all normalized between 0 and 1.
So this one over here has a high score and this one over here has a high score.
So those are equally considered the best and they're better than all the others that scored less because
they're a smaller distance from the Querier.
What if we wanted the closest one to the Querier?
Well, we could go back to our test and we could use a scoring factor to scale the score of each one.
If we chose negative one, then we're scaling the score by negative one for each of these.
Notice that now the ones that are closer to the querier have a higher score and these two at the corners
have the lowest scores.
They're are the worst scoring of all of the points.
So that's how we can score based on distance.
Now, we don't have to measure the distance to the querier.
We could measure the distance to whatever context we like if we chose our player context and go back
and look.
We'll see that now we're scoring points higher.
If they're closer to aura as that's what our context returns.
And if we go back and change our scoring factor to one again and come back, we'll see that the highest
scoring points are farthest away from aura.
So we're starting to see very quickly how useful these EQs queries can be.
Now, this is going to be used by our Ranger enemies, and I'd like the Ranger enemy to find some point
nearby somewhere in this grid area that can see aura, Right?
So we do want to filter out any points that can't trace to see aura.
But I'd also like that location to be closest to the Querier so our ranger doesn't have to go way far
out before it starts shooting at Aura.
I want it to find the closest point to itself that it can use that can still see aura.
So what I'm going to do is change the distance to to the querier in query context.
Querier.
And I'm going to choose a scoring factor of negative one so that we'll get the points closest to the
querier that can still see aura.
So that means if the Querier is over here behind a wall, then it's going to have to move all the way
up to a corner here and then it can see aura, see how this is going to work.
Now, if Aura was even farther behind a wall like here and I take my querier, I'm going to move it
a little bit.
Notice that none of these points are okay.
They're all filtered out.
We would have to move to one of these points over here to at least be around the corner enough to be
able to shoot at Aura.
So this is going to be the type of query that's going to work for us.
So I'm going to move Aura back over here a bit.
And move my test pawn and I can see that here are the best points, basically the least amount that
our AI would have to travel but still be able to see or around a corner.
It's kind of creepy, isn't it?
So now we have a nice environment query that I would like to run in our behavior tree.
So we're going to use this environment query and we'll do that next.
Great job and I'll see you in the next video.