WEBVTT

00:07.490 --> 00:08.510
Welcome back.

00:08.510 --> 00:14.450
Now we have a highlight interface which allows us to highlight any actor that we wish.

00:14.450 --> 00:21.260
And that actor provides its own implementation of the highlight and Unhighlight actor functions.

00:22.420 --> 00:29.230
This means that any given actor can have its own custom depth stencil value, which results in it highlighting

00:29.230 --> 00:31.030
a different color, and so on.

00:31.450 --> 00:39.070
Now that's great, but I'd also like our highlight interface to have an option where if we click on

00:39.070 --> 00:46.480
it, we can retrieve a move to location, a specific location that we can auto run to.

00:46.960 --> 00:54.610
This will be useful for things like checkpoints, and soon when we create dungeon entrances or map entrances

00:54.700 --> 01:00.280
that we wish to click on and move into to transition to new levels.

01:00.820 --> 01:08.410
Now for that reason, I'm going to add a new function to our highlight interface that can reset our

01:08.410 --> 01:09.580
destination.

01:09.940 --> 01:15.790
So wherever we're clicking, our player controller is setting a cached destination.

01:15.790 --> 01:21.010
We can see that in our player controller if we search for cached destination.

01:23.460 --> 01:25.410
We'll see that we're setting it in.

01:25.410 --> 01:27.360
Ability input tag held.

01:27.510 --> 01:32.790
As long as we're holding our mouse down, we're setting it to the impact point on our cursor hit.

01:32.820 --> 01:37.470
Now when we release the mouse button, we're using that cash destination.

01:37.470 --> 01:43.260
If we go over to auto run, for example, we're checking the distance to it there.

01:43.260 --> 01:48.480
If we go to ability Input tag released, we're using it here.

01:48.480 --> 01:55.260
If our follow time is less than short press threshold, then we're auto running to the cast destination.

01:55.260 --> 02:02.760
Now, what I'd like to be able to do is reset that cached destination based on our actor that we're

02:02.760 --> 02:03.570
highlighting.

02:03.570 --> 02:09.510
If this actor implements the highlight interface, which it should, I'd like to check to see if this

02:09.510 --> 02:13.200
actor would like to overwrite that destination.

02:14.220 --> 02:16.740
So what I'm going to do is add a function.

02:16.740 --> 02:20.940
To do this in the highlight interface I'm going to make a function.

02:20.940 --> 02:22.380
It can be void.

02:22.890 --> 02:26.220
If you really wanted to, you could return a boolean here.

02:26.220 --> 02:33.480
Returning true to let the player controller know that we're overwriting the cached destination, but

02:33.480 --> 02:34.590
it could be void.

02:34.620 --> 02:41.190
I don't really have a use for that boolean, so I'm going to call this set move to location, and I'm

02:41.190 --> 02:47.460
going to pass in an F vector by reference non-const and call this out destination.

02:49.330 --> 02:51.640
I'm going to make this blueprint native event.

02:54.230 --> 02:56.000
Giving it that versatility.

02:56.000 --> 03:04.700
And we're going to overwrite this in any class that we wish to overwrite this out destination.

03:05.150 --> 03:10.100
And any classes that don't wish to change it at all don't have to implement it.

03:10.490 --> 03:14.030
So our checkpoint, for example, can implement this function.

03:14.720 --> 03:27.560
Let's give it a comment that says highlight interface and another one that says end highlight interface.

03:27.860 --> 03:36.710
And we'll override virtual void set move to location implementation.

03:39.470 --> 03:40.430
Now here's the thing.

03:40.430 --> 03:46.700
I'm not getting the autocomplete for this, and it's not an override because I chose to implement this

03:46.700 --> 03:48.320
interface in C plus plus.

03:48.320 --> 03:53.030
So what I'm going to do, I still have the editor open is I'm going to take my checkpoint.

03:53.030 --> 04:00.890
I'm going to go ahead and just remove my implementation of these in blueprint, and just remove my interface

04:00.890 --> 04:03.860
here from my implemented interfaces.

04:03.860 --> 04:08.300
It's going to ask if I want to transfer the interface functions to be part of this blueprint.

04:08.300 --> 04:09.590
I don't want that.

04:09.590 --> 04:10.940
I'm going to click on no.

04:10.940 --> 04:14.090
So now the checkpoint no longer highlights the interface.

04:14.090 --> 04:17.870
We can see that by pressing play we don't get highlight behavior.

04:18.620 --> 04:21.170
I'm going to implement this in C plus plus now.

04:21.170 --> 04:23.060
So I'm going to close the editor.

04:23.060 --> 04:26.600
And here in the checkpoint I'm going to implement.

04:27.610 --> 04:28.840
Publicly public.

04:28.840 --> 04:31.120
I highlight interface.

04:31.120 --> 04:33.820
We'll get that highlight interface header included.

04:33.820 --> 04:38.140
And now we should be able to override this function.

04:38.560 --> 04:41.680
I must have a typo set move to location.

04:42.440 --> 04:44.420
Yes, it needs an F vector.

04:46.450 --> 04:50.800
A vector reference out destination.

04:51.850 --> 04:58.450
So now that checkpoints implement this function, a checkpoint can return any destination we wish for

04:58.450 --> 05:00.190
our character to move to.

05:00.820 --> 05:07.030
I'm going to go ahead and generate the definition, but we'll keep it blank for now as checkpoints are

05:07.030 --> 05:09.640
going to need to return something.

05:09.640 --> 05:12.460
So we'll figure out what that should be soon.

05:12.460 --> 05:18.520
But now that checkpoint implements I highlight interface, I'd like to provide the implementation for

05:18.520 --> 05:22.690
highlight and Unhighlight actor here in C plus plus.

05:22.690 --> 05:29.050
That way we don't have to go in and implement it for all blueprints that we wish to have derived from

05:29.050 --> 05:30.310
the checkpoint class.

05:30.310 --> 05:38.590
So I'm going to override virtual void, highlight actor implementation and virtual Void and highlight

05:38.590 --> 05:40.510
actor implementation.

05:40.510 --> 05:43.840
And we'll go ahead and implement these functions.

05:46.990 --> 05:48.910
Now highlight actor.

05:48.910 --> 05:52.420
I'm going to want to set render custom depth to true.

05:52.600 --> 05:54.010
And we're doing that in the enemy.

05:54.010 --> 06:00.130
If we go to our enemy highlight actor implementation, we're getting the mesh and calling set render

06:00.130 --> 06:01.000
custom depth.

06:01.000 --> 06:08.440
We're even setting the custom depth stencil value to red, something we could just do in the constructor

06:08.440 --> 06:10.660
for both the mesh and the weapon.

06:10.660 --> 06:13.510
Why don't we go ahead and just do that?

06:14.880 --> 06:16.290
We don't need it here.

06:16.290 --> 06:19.050
I just copied those three lines.

06:19.050 --> 06:26.010
And in the constructor I'm going to go ahead and paste them removing that middle unnecessary line.

06:26.010 --> 06:29.580
So we're setting the custom depth stencil value to red here.

06:30.150 --> 06:37.470
Now if we set this in the constructor we can force that update right away by taking the mesh and call

06:38.610 --> 06:40.620
Mark render state dirty.

06:40.860 --> 06:42.660
And we can do that on the weapon as well.

06:42.660 --> 06:46.920
Weapon mark render state dirty.

06:46.920 --> 06:51.930
So now we're not setting this every time we highlight and unhighlight the enemies.

06:51.930 --> 06:57.510
But the point is that we're setting render custom depth to true or false.

06:57.510 --> 06:59.760
When we want to highlight or unhighlight.

06:59.760 --> 07:03.330
We can do this in the checkpoint as well with our checkpoint mesh.

07:03.330 --> 07:10.920
So we're going to say checkpoint mesh for highlight actor implementation set render custom depth.

07:12.060 --> 07:12.690
Passing in.

07:12.690 --> 07:13.320
True.

07:14.610 --> 07:16.380
And for Unhighlight actor.

07:17.200 --> 07:24.220
We'll call set render custom depth passing in false and we can set that custom depth stencil value in

07:24.220 --> 07:25.150
the constructor.

07:25.150 --> 07:28.450
Right here we can say checkpoint mesh.

07:31.860 --> 07:39.390
Set custom depth stencil value and we have values in aura dot h.

07:39.720 --> 07:42.270
I'd like to use custom depth ten.

07:44.830 --> 07:46.360
So we'll pass that in.

07:47.580 --> 07:49.350
And include ora H.

07:49.350 --> 07:50.730
So that's defined.

07:51.560 --> 07:56.630
And we can take checkpoint mesh and mark render state dirty.

07:56.810 --> 08:01.130
Now our highlight functionality has been moved into C plus plus.

08:01.460 --> 08:08.360
But if we want to be able to change that custom depth stencil value for any actor derived from checkpoint,

08:08.360 --> 08:09.740
this could be a variable.

08:09.740 --> 08:12.470
So let's go ahead and make a variable.

08:12.470 --> 08:15.800
Here in checkpoint this will be an int 32.

08:15.800 --> 08:18.740
And we'll call this custom Depth stencil.

08:20.180 --> 08:21.290
Override.

08:23.730 --> 08:32.460
And I'll go ahead and set it to Custom Depth ten, which means that Ora H should be included here in

08:32.460 --> 08:35.580
the header file, and we don't need it included here.

08:38.440 --> 08:45.460
We'll just make sure it's here in the header file, and we'll make this something we can set in the

08:45.460 --> 08:47.860
blueprint with edit defaults only.

08:48.190 --> 08:54.190
So now we can use custom depth stencil override right here in the constructor instead of custom depth

08:54.190 --> 08:54.790
tan.

08:55.430 --> 08:57.170
Okay, so that's all great.

08:57.170 --> 08:59.210
We're still doing the same thing.

08:59.210 --> 09:03.920
We're just setting render custom depth from C plus plus rather than in blueprint.

09:04.160 --> 09:07.430
What about this set move to location implementation?

09:07.880 --> 09:15.140
Well, for a checkpoint, I'd like some kind of object that we can place in our checkpoint blueprint.

09:15.140 --> 09:16.610
Relative to the root.

09:16.610 --> 09:20.630
We could use an F vector, or we could use a scene component.

09:20.630 --> 09:26.420
I like scene components because we can attach a billboard to them and make them easy to see.

09:26.420 --> 09:30.620
So I'm going to make a U scene component.

09:31.940 --> 09:34.640
And this can be a t object pointer.

09:36.100 --> 09:37.630
Of type using component.

09:37.630 --> 09:40.450
And I'm going to call this move to.

09:42.200 --> 09:43.370
Component.

09:45.750 --> 09:49.350
And this will be a new property with visible anywhere.

09:49.440 --> 09:52.680
And we're going to construct this in the checkpoint constructor.

09:54.700 --> 09:57.910
Move to component equals.

09:57.910 --> 10:02.590
We'll use Createdefaultsubobject with you scene component.

10:04.090 --> 10:09.100
We'll call this move to component and we'll attach it to the root component.

10:09.430 --> 10:13.090
So we'll call setup attachment get root component.

10:13.990 --> 10:18.700
And we'll move this to a specific location in the blueprint.

10:18.700 --> 10:27.760
And our override of set move to location is just going to take this out destination out destination

10:27.760 --> 10:33.970
and set it equal to move to component get component location.

10:34.450 --> 10:40.630
And now we can overwrite any vector we pass into this, such as in the player controller where we're

10:40.630 --> 10:44.650
about to auto run to cached destination.

10:44.650 --> 10:47.740
If we like, we can check this actor.

10:47.740 --> 10:57.700
We can say if is valid, this actor and this actor.

10:59.630 --> 11:03.050
Implements you highlight interface.

11:04.310 --> 11:05.840
Then we can call.

11:05.870 --> 11:07.730
I highlight interface.

11:08.060 --> 11:09.770
Execute set.

11:09.770 --> 11:11.000
Move to location.

11:11.000 --> 11:16.430
We have to pass this actor in first and then we can pass in cached destination.

11:16.700 --> 11:19.880
Now the enemies do implement this interface.

11:19.970 --> 11:26.390
So it would be good if we explicitly define exactly what should happen in that case.

11:26.390 --> 11:27.800
Just so it's clear.

11:27.800 --> 11:36.440
So we can come into the enemy and override virtual void set.

11:36.470 --> 11:40.880
Move to location implementation override.

11:40.880 --> 11:43.940
And for this definition we should do nothing.

11:47.060 --> 11:49.880
Do not change out.

11:49.880 --> 11:51.020
Destination.

11:52.790 --> 11:56.120
So that way it's clear what our intentions are.

11:56.150 --> 12:04.100
Our aura enemy doesn't want to do anything in this case now, because our checkpoint is overwriting

12:04.100 --> 12:05.600
this location.

12:06.150 --> 12:13.710
If we click on a checkpoint, then we should now get auto run behavior to a specific destination.

12:13.710 --> 12:20.610
And before we compile and launch one last little detail, this is a little thing that I'd like to do,

12:20.610 --> 12:27.600
is if we are overwriting this destination, I don't want to show my Click Niagara system.

12:27.990 --> 12:35.520
If I'm clicking on a checkpoint or a map entrance, once we make those, I don't want to show this Niagara

12:35.520 --> 12:36.180
system.

12:36.180 --> 12:39.930
So what I'll do is have this in an else case right here.

12:39.930 --> 12:45.840
If we're not overwriting the destination, then we'll have this line here.

12:45.900 --> 12:48.000
So I'm going to cut that and put it here.

12:48.330 --> 12:55.800
And we could make this compact a little bit by taking the if and moving it right after the else to make

12:55.800 --> 12:56.910
it an else if.

12:56.910 --> 13:00.780
And then we don't have so much nesting here so we can do that.

13:00.780 --> 13:07.380
So that way if we click on a checkpoint and we're auto running to it, I don't want to show those Niagara

13:07.380 --> 13:12.780
system particles because they may be showing us where we clicked, which could be different than where

13:12.780 --> 13:16.500
we end up due to overwriting cache destination.

13:16.500 --> 13:21.030
So it's a small detail, but I felt it was important enough.

13:21.030 --> 13:27.630
Okay, so now we can move that scene component on the checkpoint to a specific location that we'd like

13:27.630 --> 13:28.650
to run to.

13:28.950 --> 13:30.390
So let's test this out.

13:31.990 --> 13:32.500
Okay.

13:32.500 --> 13:34.990
So I'm going to get my checkpoint blueprint back open.

13:34.990 --> 13:39.550
And I'm going to go into the viewport because now I have a move two component.

13:39.550 --> 13:45.040
Now by default it's set to the root components location as it's attached to that.

13:45.040 --> 13:47.950
But I'm going to go into perspective right.

13:47.950 --> 13:49.810
So I can see this from the right.

13:49.810 --> 13:53.620
And I'm going to choose where I'd like to move to.

13:53.620 --> 13:58.780
When we click on one of these I'm just going to take the move two component and move it to about right

13:58.780 --> 13:59.140
here.

13:59.140 --> 14:02.710
So that way we'll move to this location specifically.

14:03.680 --> 14:05.210
Let's test this out.

14:06.560 --> 14:08.210
I'm going to save all first.

14:09.060 --> 14:11.490
I'm going to press play and we're testing a couple things.

14:11.490 --> 14:17.280
First, do we get highlight behavior as we're doing this now in C plus plus and yes, we do.

14:17.310 --> 14:20.400
Now if I click anywhere on this thing.

14:20.990 --> 14:26.630
Well, we actually need to be somewhere where there's a nav mesh bounds volume, don't we?

14:26.630 --> 14:28.940
So now if I click anywhere on this one.

14:29.840 --> 14:34.370
We went exactly to this location on it and we didn't show our particles.

14:34.370 --> 14:37.130
Now, if I click elsewhere, I get the particles right.

14:37.130 --> 14:42.740
But if I click anywhere on here we go specifically to that scene component location.

14:42.740 --> 14:50.150
And to prove that we can go to Perspective view and we can put it anywhere, say on the opposite side

14:50.150 --> 14:51.410
of it back here.

14:52.850 --> 14:54.320
That's going to be the back of it.

14:54.320 --> 14:55.700
Let's try that.

15:00.270 --> 15:01.860
I'm going to click right here.

15:02.980 --> 15:04.540
And I went to the back of it.

15:04.540 --> 15:10.660
So this is what's going to allow us to create anything that we wish.

15:10.690 --> 15:14.410
A set of stairs, a tunnel, anything that we like.

15:14.410 --> 15:20.710
And we'll have this move to component that can help us to determine where we should auto run to when

15:20.710 --> 15:22.210
we click on that thing.

15:22.210 --> 15:30.370
And that's going to be pivotal in creating any map, entrances or exits that we can use to transition

15:30.370 --> 15:31.600
to another map.

15:32.020 --> 15:34.390
So this is a great milestone.

15:35.630 --> 15:36.920
So excellent job.

15:36.920 --> 15:42.650
We're going to continue with this in the next video, where we start to create a new class based on

15:42.650 --> 15:47.840
our checkpoint that will allow us to transition to other levels.

15:47.870 --> 15:50.090
Excellent job, and I'll see you soon.
