WEBVTT

00:07.030 --> 00:14.920
Okay, so we have our click and hold to move, but we want to click and release to get that auto run

00:14.920 --> 00:15.850
behavior.

00:15.970 --> 00:19.690
So that's going to involve a little bit more work.

00:19.810 --> 00:28.690
Now we're concerned with ability input tag released at this point and we want to know if when we release

00:28.690 --> 00:35.920
an input, is that input our left mouse button, just like we did right here in ability input tag held.

00:35.950 --> 00:36.970
We checked.

00:37.000 --> 00:39.610
Does the input tag match exactly.

00:39.610 --> 00:41.400
The left mouse button tag.

00:41.410 --> 00:47.680
Why don't we go ahead and just copy those lines and paste them right in here replacing what's there.

00:47.680 --> 00:52.120
And if it's not the left mouse button, we have that negation operator there.

00:52.150 --> 00:56.590
We want to call ability input tag released.

00:56.680 --> 01:01.820
So we're going to call ability input tag released here and return.

01:01.840 --> 01:07.400
Now that's if we're not the left mouse button, but if we are the left mouse button, we should see

01:07.400 --> 01:11.560
if we're targeting just like we did here in ability input tag held.

01:11.570 --> 01:19.250
So we're going to have that same if be targeting right here only we're going to call ability input tag

01:19.250 --> 01:21.890
released instead of held.

01:21.890 --> 01:29.810
And then if we've made it this far and we get to the else case here, then that means we are the left

01:29.810 --> 01:30.720
mouse button.

01:30.740 --> 01:32.990
Otherwise we wouldn't have made it this far.

01:32.990 --> 01:34.370
And we're not targeting.

01:34.370 --> 01:38.570
So we're concerned with our click to move behavior at this point.

01:38.600 --> 01:40.630
So what are we doing down here?

01:40.640 --> 01:46.250
Well, we're collecting the follow time and then of course, adding movement input.

01:46.250 --> 01:48.860
This is on a frame by frame basis.

01:48.860 --> 01:52.730
But when we release, we want to check that follow time.

01:52.730 --> 01:56.060
We want to see if it was a short press or not.

01:56.090 --> 01:57.350
So we can check that.

01:57.350 --> 02:04.910
We can say if follow time is less than or equal to our short press threshold.

02:05.300 --> 02:09.120
If that's the case, well then we want to do something different.

02:09.140 --> 02:11.780
We want to find a path.

02:11.780 --> 02:18.110
We want to create a navigation path, a set of points to follow.

02:18.110 --> 02:19.730
So how do we do that?

02:19.760 --> 02:28.490
Well, there's a function that belongs in the static function library that is you navigation system

02:28.520 --> 02:37.460
V1 and the function is find path to location synchronously.

02:39.230 --> 02:44.870
Now, if we're going to use this, we need to include navigation system dot h as we see right here.

02:44.870 --> 02:51.320
So I'm going to use alt enter to include that and find path to location synchronously takes a number

02:51.320 --> 02:52.010
of arguments.

02:52.010 --> 02:54.760
For one, it needs a world context object.

02:54.770 --> 02:56.300
So let's give it one.

02:56.300 --> 02:59.780
We'll give it this and it needs a path start.

02:59.840 --> 03:03.650
So we're going to want our controlled ponds location.

03:03.650 --> 03:06.110
So let's go ahead and get that pond.

03:06.110 --> 03:11.390
We're going to say a pond controlled pond equals get pond.

03:11.840 --> 03:18.080
And here in the if we're going to check if follow time is less than short press threshold and we're

03:18.080 --> 03:19.400
going to have an end here.

03:19.400 --> 03:21.620
And also check controlled pond.

03:24.120 --> 03:31.170
So in here, we know we have a controlled pawn so we can take controlled pawn and call get actor location.

03:31.170 --> 03:33.540
That will be the starting point.

03:35.290 --> 03:38.710
For find path to location synchronously.

03:38.740 --> 03:44.830
Now the next input is the path end and of course we have our cached destination for that.

03:44.830 --> 03:48.730
So we're going to pass in cached destination for that.

03:49.000 --> 03:51.050
So what does this return?

03:51.070 --> 03:54.470
It returns a new navigation path.

03:54.490 --> 04:02.920
We're going to go ahead and store that in a local you navigation path pointer.

04:03.280 --> 04:05.530
We'll call it nav path.

04:05.530 --> 04:11.350
And if we're going to check this pointer, well, we might as well just wrap this whole thing in an

04:11.350 --> 04:13.360
If so, we'll go ahead and do that.

04:13.360 --> 04:20.500
I'll remove that semicolon at the end and instead we'll have this all in an if statement like so.

04:20.530 --> 04:24.060
Now we have a path and a navigation path.

04:24.070 --> 04:26.350
Our nav path pointer.

04:26.590 --> 04:32.620
If we type nav path, it should have something called path points.

04:33.070 --> 04:37.370
And if we hover over path points, it's a array of vectors.

04:37.370 --> 04:45.050
So this is the path that we're concerned with and it starts at the controlled pawns location and it

04:45.050 --> 04:47.060
ends at the destination.

04:47.060 --> 04:51.020
So we have a set of points that we can add to our spline.

04:51.170 --> 04:57.920
Now I'd like to do that, and I'd also like to sort of draw some debug spheres for each of these path

04:57.920 --> 05:00.500
points so we can see what we're working with.

05:00.650 --> 05:03.020
So we'll handle both of those things.

05:03.020 --> 05:09.320
So first we're going to take our spline and each time we set the spline points, we should clear all

05:09.320 --> 05:11.500
the points out that were there before.

05:11.510 --> 05:16.310
So we're going to call clear spline points and then we're going to loop through our path.

05:16.310 --> 05:20.900
We're going to say for const F vector reference.

05:22.040 --> 05:23.420
Point, location or point.

05:23.450 --> 05:26.390
Look in nav path.

05:27.540 --> 05:28.800
Path points.

05:29.790 --> 05:36.120
So for each of these, we're going to first of all, add them to the spline as a spline point, which

05:36.120 --> 05:45.000
we can use spline, add spline point for that and add spline point takes a position that's going to

05:45.000 --> 05:51.360
be the point location or point look, and it also takes in a spline coordinate space.

05:51.360 --> 05:54.890
And I'm just going to make things simple and use world space.

05:54.900 --> 06:01.170
So we're going to say e spline coordinate space, double colon world.

06:01.920 --> 06:04.950
And that's how we add a point to our spline.

06:04.950 --> 06:10.110
So we're looping through our whole path, adding spline points to the spline.

06:10.320 --> 06:11.310
Perfect.

06:11.430 --> 06:14.520
Now what I'd like to do is draw some debug spheres.

06:14.520 --> 06:22.290
So we're going to say draw debug sphere and I'm going to pass in get world for the world requirement

06:22.470 --> 06:29.040
and for the center we're going to use point look for the radius.

06:29.040 --> 06:33.840
I'm going to make these relatively small eight point F.

06:35.190 --> 06:36.000
Segments.

06:36.000 --> 06:38.130
We can have eight segments as well.

06:38.130 --> 06:45.240
That's fine for the color for these spline points, I'm going to make them green, so f color green

06:45.330 --> 06:51.750
and for be persistent lines, we're going to say false and we'll just draw this for a duration.

06:51.750 --> 06:59.280
So for the lifetime, let's draw it for five seconds, five F, So now we'll get our spline points drawn

06:59.280 --> 07:01.110
so we can see what's going on.

07:01.410 --> 07:05.460
Now, another thing is we're adding spline points.

07:05.490 --> 07:13.920
Our spline will now have points in our path, which means our be auto running boolean should be set

07:13.920 --> 07:14.850
to true.

07:15.210 --> 07:20.790
And we're also no longer holding the mouse button down.

07:20.790 --> 07:24.150
This is in the released function after all.

07:24.150 --> 07:31.890
So that also means that we should reset our follow time and we should also set our be targeting Boolean

07:31.890 --> 07:33.060
to false.

07:33.300 --> 07:37.390
So all of that can be done here inside the else case.

07:37.390 --> 07:40.420
So I'm going to put that right here at the bottom.

07:40.420 --> 07:49.150
We're going to say follow time is reset to zero and be targeting equals false.

07:49.150 --> 07:52.540
We're going to have to check that every time we click.

07:52.540 --> 07:56.650
So as we release, we're going to set that back to false.

07:56.920 --> 07:58.180
All right.

07:58.180 --> 08:01.300
So looking pretty good now.

08:01.300 --> 08:04.720
We're not going to be moving or anything like that.

08:04.750 --> 08:07.840
All we're doing is adding points to our spline.

08:07.840 --> 08:09.190
But we can test this out.

08:09.190 --> 08:12.760
We can see if we draw some spline points for a path.

08:12.760 --> 08:19.420
So I'd like to at least make sure this part's working before we go and implement actually moving.

08:20.080 --> 08:20.500
Okay.

08:20.500 --> 08:23.800
So I'm getting a linker error now.

08:23.800 --> 08:31.450
That does make sense because I'm now using this new navigation system v one that's going to require

08:31.450 --> 08:34.720
a module include in our build file.

08:35.220 --> 08:38.160
Now, when in doubt, you can Google it.

08:38.190 --> 08:43.410
We can Google find path to location synchronously.

08:45.380 --> 08:53.330
And here it is you navigation system V1 find path to location synchronously and it's in module navigation

08:53.330 --> 08:54.140
system.

08:54.140 --> 08:58.820
We can just copy that and add it to our modules here.

08:59.180 --> 09:02.810
We're using it in a CPP that's a private folder.

09:02.810 --> 09:06.010
So we can simply add this to Aura.

09:06.380 --> 09:11.120
Build CSS right there in private dependency module names.

09:13.270 --> 09:15.940
So attempting to compile again.

09:16.900 --> 09:18.670
We have a successful compile.

09:18.670 --> 09:19.870
So let's run in debug mode.

09:19.870 --> 09:23.050
This time I'm going to go ahead and close out of the build file.

09:24.410 --> 09:24.980
Okay.

09:24.980 --> 09:31.580
So now that we're using that pathfinding algorithm, if I press play and I click.

09:33.230 --> 09:35.000
We're not going to get anything.

09:35.000 --> 09:40.160
And that's because we need a nav mesh bounds volume first and foremost.

09:40.160 --> 09:41.330
So let's see.

09:41.330 --> 09:48.860
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

09:49.040 --> 09:51.230
now if I click this dropdown.

09:52.200 --> 09:53.310
Under volumes.

09:53.310 --> 09:55.290
We have NAV mesh bounds volume.

09:55.290 --> 10:00.720
I can click and drag one in and scale this thing up.

10:01.050 --> 10:05.280
I'm going to press P so I can see it and I'm going to make it larger.

10:06.750 --> 10:13.080
I'd like it to encompass my entire area, which, by the way, is looking pretty boring with the checkered

10:13.080 --> 10:13.560
pattern.

10:13.560 --> 10:16.010
So I might want to change that too.

10:16.020 --> 10:20.040
But for now, let's just get this nav mesh bounds volume.

10:20.190 --> 10:21.410
I think we're good.

10:21.540 --> 10:23.460
Hitting P to hide it again.

10:23.460 --> 10:27.660
And if I press play and click now I get those points.

10:28.140 --> 10:29.070
Excellent.

10:29.960 --> 10:34.790
Now light green is a little hard to see, but if I click, I have two points here.

10:34.790 --> 10:41.090
So we have a spline with two points, but let's just see if this works with obstacles.

10:41.270 --> 10:43.460
I'd like to put something in the way.

10:43.460 --> 10:48.350
So I'm going to go to assets, go to Dungeon and Beacon.

10:48.350 --> 10:51.950
Here's a nice big pillar looking thing.

10:52.130 --> 10:53.880
I'm going to drag one in there.

10:53.900 --> 11:00.650
Now I do need to make sure it has collision, so I'm going to open up the static mesh, go to show check,

11:00.650 --> 11:01.610
simple collision.

11:01.610 --> 11:03.500
And we do have simple collision.

11:03.860 --> 11:09.440
And of course, we could just press P and make sure that it is making a hole in the nav mesh.

11:09.440 --> 11:14.300
That's what's going to determine if we get a path generated around it.

11:14.300 --> 11:20.840
So if I click on the other side of it, we can generate some path points that go around it.

11:20.840 --> 11:21.890
Look at that.

11:22.530 --> 11:25.980
So I'll let those go away and I'll click on the other side of it.

11:25.980 --> 11:27.230
And there we have it.

11:27.240 --> 11:30.650
We have a point going from here to here to there.

11:30.660 --> 11:34.650
So we are generating a path and that's looking great.

11:34.710 --> 11:41.160
So the last thing is to actually implement the auto running behavior that's going to involve the tick

11:41.160 --> 11:46.020
function and we're going to handle that in the next video.

11:46.050 --> 11:47.970
Great job and I'll see you soon.
