Welcome back.
Now we've created an environment query and we have an X testing Pon that's testing that query and it's
showing some debug locations for us for each of those items generated by our generator.
Now our generator is generating a path in grid generating around the query or the query for being,
in this case, the testing Pon.
Now we can run tests on all of the points generated by our generator and we can add those tests pretty
easily by right clicking on the generator and selecting add test.
And we have a few different types of tests.
One of those is the trace.
I'd like to check out that one first.
Now the trace is going to trace for each of these points to some kind of destination that we choose,
and by default, it traces against the visibility channel.
So if we click on the blue Trace to query or on visibility, we see the details for this given test.
And under test, we see test purpose.
Now the test purpose is what determines what we do with each point.
Do we want to filter them out?
Do we want to score them or do we want to do both?
Now a trace is a sort of yes or no question.
If we trace to some target, can we hit that target or is something in the way?
That's what the trace is really good for.
So we can choose to have this filter out all points that cannot trace to a given target or the opposite.
We can filter out all points that can.
So I'm going to change this to filter only and we can trace to a target in the test details panel.
The target is called a context, or we can trace from the context to each given point.
Now the context by default is set to environment query context Querier, which means that we'll be tracing
to the querier.
And in our case, we just have this testing pawn here.
The testing pawn doesn't really have any components that will block the visibility channel.
So a trace doesn't mean a whole lot when we don't have a context that we can trace and hit.
But we don't have to trace to the querier.
We don't have to trace to the testing pawn or the pawn that owns this environment query.
We can choose any context we want.
In fact, a context is a class that we can make and determine exactly what we're going to trace to.
So we're going to create a environment query context and define exactly what it is we'd like to trace
to.
So to make an environment query context, we're going to go into i x our X folder, we're going to right
click, create a Blueprint class.
And the class that we're interested in is e env query context and we need environment query context,
blueprint base or env query context blueprint base.
Let's select that.
Now we have a environment query context and I'm going to name this X underscore player context.
So I'd like this context to determine exactly what we should be able to trace towards and try to hit.
So I'm going to open up my X player context and the way that we determine what this context returns
is, we override a function called provide actor set.
We can also provide location set, and we're going to return a set of actors or locations.
We could also provide a single actor or a single location if we wanted to do that.
We're going to choose provide actor set and notice that we return an array of actor object references.
This is going to be pretty simple.
We're going to use get all actors of class.
And we're going to filter this by our Aura class.
We're going to use BP, underscore aura character.
So we're going to get all actors of the Aura character class.
So this is not a very expensive operation.
We only have one or in the case of a multiplayer game, perhaps several, but we won't have that many.
So we're going to return that.
So this context returns an array of all actors of the BP Aura character class.
I'm going to compile and save that.
And now if I go back to my environment query with my trace, I can change this context to ex player
context.
And now look, it's tracing to ex player context on visibility.
What happens then?
Well, let's go back to our map.
Notice that all of these are red and they have a score of zero.
That's what these numbers are.
They're the score.
Well, that's because there's no aura character to trace to.
But we can grab an aura character.
We can go to blueprints, character, aura and drag in a BP or a character.
Let's go ahead and grab one of those, drag it in.
So now we have an aura character in the world that our items can trace to.
And I'm going to select my testing pawn and just move it up a little bit above the ground just a bit.
And that way we can make sure that our points are not going to trace and hit the ground.
Okay, so we're performing a trace.
And if we go back to our environment query, we have something called Bool Match.
Now this boolean value is what we use to determine whether we want to filter things out or keep them
in based on this trace.
If we uncheck it and go back, notice all the points are red.
If we check bool, match and go back, all the points are blue.
So which one is which?
Which one is the hit and which one is not?
Well, we can figure that out pretty easily by dragging in some geometry to block the way.
I'm going to go to assets and dungeon and let's get a wall or a cube of some kind.
Here's a static mesh tile.
Three by three by three.
I'm going to bring that in.
It's actually quite large.
And then I'll select my testing pawn and I'll move it just slightly.
And after I move it slightly, we've kicked it into gear.
Sometimes you have to move it a little bit to update it when the environment changes.
So now check out what's happening.
We have a number of points here and some of them are blue and some of them are red.
Now, looking back at my environment query bool match is set to false.
If I check that, change it to true.
Now we'll see that most of these points are blue and the points that would not hit the player, the
ones that are blocked by this geometry are red.
So if we only want the points that can see the player, the points that can trace to the player unblocked,
we're going to want to set that boolean to false.
And then we get all those points that can trace to the player and not hit something in the way.
Okay.
Now notice that some of the points are inside and those ones actually are able to trace to aura.
They're not hitting something because this static mesh isn't blocking from the inside.
So that's something to be aware of.
You have to keep in mind that this grid can contain points that may be inside of geometry.
So we really don't want any points that could be inside of some geometry.
Right?
So there are a couple of things we can do about that.
For one, I'm going to take this cube.
I'm going to right click on it and edit it.
Now, this cube may or may not have simple geometry.
We can click on show and choose simple collision.
And if we don't see any green collision volumes, then we don't have any simple collision.
We can go up to collision and add box simplified collision to add a simple collision that's going to
affect any NAV mesh bounds volume.
On top of that, we don't have a nav mesh, so we can go into the dropdown and go to volumes and drag
in a nav mesh bounds volume.
And we can scale up that nav mesh bounds volume here.
And if I press P, I can see the extent of that nav mesh and we can see that now this block is putting
a hole in the nav mesh.
So now that we have that, if I select my testing pawn and move it just a bit, we'll now see that there
are no points generated because it's a pathing grid.
Pathing has to do with pathfinding, which has to do with AI, which uses the NAV mesh bounds volume.
So pathing grid is not going to give us any points that are not navigable, something that an AI character
could not walk on.
So that's something to be aware of.
So now that we know how to run tests on the different items generated by our generators, we're going
to want to run more tests because we want to filter out all of these points for the best one.
We want to get one that is ranked better than all the others, and we're going to do that by scoring
the points, and we'll do that in the next video.
So great job and I'll see you in the next video.