Okay, so we have our click and hold to move, but we want to click and release to get that auto run
behavior.
So that's going to involve a little bit more work.
Now we're concerned with ability input tag released at this point and we want to know if when we release
an input, is that input our left mouse button, just like we did right here in ability input tag held.
We checked.
Does the input tag match exactly.
The left mouse button tag.
Why don't we go ahead and just copy those lines and paste them right in here replacing what's there.
And if it's not the left mouse button, we have that negation operator there.
We want to call ability input tag released.
So we're going to call ability input tag released here and return.
Now that's if we're not the left mouse button, but if we are the left mouse button, we should see
if we're targeting just like we did here in ability input tag held.
So we're going to have that same if be targeting right here only we're going to call ability input tag
released instead of held.
And then if we've made it this far and we get to the else case here, then that means we are the left
mouse button.
Otherwise we wouldn't have made it this far.
And we're not targeting.
So we're concerned with our click to move behavior at this point.
So what are we doing down here?
Well, we're collecting the follow time and then of course, adding movement input.
This is on a frame by frame basis.
But when we release, we want to check that follow time.
We want to see if it was a short press or not.
So we can check that.
We can say if follow time is less than or equal to our short press threshold.
If that's the case, well then we want to do something different.
We want to find a path.
We want to create a navigation path, a set of points to follow.
So how do we do that?
Well, there's a function that belongs in the static function library that is you navigation system
V1 and the function is find path to location synchronously.
Now, if we're going to use this, we need to include navigation system dot h as we see right here.
So I'm going to use alt enter to include that and find path to location synchronously takes a number
of arguments.
For one, it needs a world context object.
So let's give it one.
We'll give it this and it needs a path start.
So we're going to want our controlled ponds location.
So let's go ahead and get that pond.
We're going to say a pond controlled pond equals get pond.
And here in the if we're going to check if follow time is less than short press threshold and we're
going to have an end here.
And also check controlled pond.
So in here, we know we have a controlled pawn so we can take controlled pawn and call get actor location.
That will be the starting point.
For find path to location synchronously.
Now the next input is the path end and of course we have our cached destination for that.
So we're going to pass in cached destination for that.
So what does this return?
It returns a new navigation path.
We're going to go ahead and store that in a local you navigation path pointer.
We'll call it nav path.
And if we're going to check this pointer, well, we might as well just wrap this whole thing in an
If so, we'll go ahead and do that.
I'll remove that semicolon at the end and instead we'll have this all in an if statement like so.
Now we have a path and a navigation path.
Our nav path pointer.
If we type nav path, it should have something called path points.
And if we hover over path points, it's a array of vectors.
So this is the path that we're concerned with and it starts at the controlled pawns location and it
ends at the destination.
So we have a set of points that we can add to our spline.
Now I'd like to do that, and I'd also like to sort of draw some debug spheres for each of these path
points so we can see what we're working with.
So we'll handle both of those things.
So first we're going to take our spline and each time we set the spline points, we should clear all
the points out that were there before.
So we're going to call clear spline points and then we're going to loop through our path.
We're going to say for const F vector reference.
Point, location or point.
Look in nav path.
Path points.
So for each of these, we're going to first of all, add them to the spline as a spline point, which
we can use spline, add spline point for that and add spline point takes a position that's going to
be the point location or point look, and it also takes in a spline coordinate space.
And I'm just going to make things simple and use world space.
So we're going to say e spline coordinate space, double colon world.
And that's how we add a point to our spline.
So we're looping through our whole path, adding spline points to the spline.
Perfect.
Now what I'd like to do is draw some debug spheres.
So we're going to say draw debug sphere and I'm going to pass in get world for the world requirement
and for the center we're going to use point look for the radius.
I'm going to make these relatively small eight point F.
Segments.
We can have eight segments as well.
That's fine for the color for these spline points, I'm going to make them green, so f color green
and for be persistent lines, we're going to say false and we'll just draw this for a duration.
So for the lifetime, let's draw it for five seconds, five F, So now we'll get our spline points drawn
so we can see what's going on.
Now, another thing is we're adding spline points.
Our spline will now have points in our path, which means our be auto running boolean should be set
to true.
And we're also no longer holding the mouse button down.
This is in the released function after all.
So that also means that we should reset our follow time and we should also set our be targeting Boolean
to false.
So all of that can be done here inside the else case.
So I'm going to put that right here at the bottom.
We're going to say follow time is reset to zero and be targeting equals false.
We're going to have to check that every time we click.
So as we release, we're going to set that back to false.
All right.
So looking pretty good now.
We're not going to be moving or anything like that.
All we're doing is adding points to our spline.
But we can test this out.
We can see if we draw some spline points for a path.
So I'd like to at least make sure this part's working before we go and implement actually moving.
Okay.
So I'm getting a linker error now.
That does make sense because I'm now using this new navigation system v one that's going to require
a module include in our build file.
Now, when in doubt, you can Google it.
We can Google find path to location synchronously.
And here it is you navigation system V1 find path to location synchronously and it's in module navigation
system.
We can just copy that and add it to our modules here.
We're using it in a CPP that's a private folder.
So we can simply add this to Aura.
Build CSS right there in private dependency module names.
So attempting to compile again.
We have a successful compile.
So let's run in debug mode.
This time I'm going to go ahead and close out of the build file.
Okay.
So now that we're using that pathfinding algorithm, if I press play and I click.
We're not going to get anything.
And that's because we need a nav mesh bounds volume first and foremost.
So let's see.
I'm going to set number of players back to one for now and I'm going to drag in a nav mesh bounds volume
now if I click this dropdown.
Under volumes.
We have NAV mesh bounds volume.
I can click and drag one in and scale this thing up.
I'm going to press P so I can see it and I'm going to make it larger.
I'd like it to encompass my entire area, which, by the way, is looking pretty boring with the checkered
pattern.
So I might want to change that too.
But for now, let's just get this nav mesh bounds volume.
I think we're good.
Hitting P to hide it again.
And if I press play and click now I get those points.
Excellent.
Now light green is a little hard to see, but if I click, I have two points here.
So we have a spline with two points, but let's just see if this works with obstacles.
I'd like to put something in the way.
So I'm going to go to assets, go to Dungeon and Beacon.
Here's a nice big pillar looking thing.
I'm going to drag one in there.
Now I do need to make sure it has collision, so I'm going to open up the static mesh, go to show check,
simple collision.
And we do have simple collision.
And of course, we could just press P and make sure that it is making a hole in the nav mesh.
That's what's going to determine if we get a path generated around it.
So if I click on the other side of it, we can generate some path points that go around it.
Look at that.
So I'll let those go away and I'll click on the other side of it.
And there we have it.
We have a point going from here to here to there.
So we are generating a path and that's looking great.
So the last thing is to actually implement the auto running behavior that's going to involve the tick
function and we're going to handle that in the next video.
Great job and I'll see you soon.