WEBVTT

00:06.420 --> 00:09.730
Welcome back to this series on NAV measures.

00:09.780 --> 00:12.840
So far we've created a flock of chompers.

00:12.870 --> 00:19.740
Now, if you have a look in the assets folder, I've also added a big jumper prefab in there so you

00:19.740 --> 00:20.640
can bring him in.

00:20.670 --> 00:24.330
He's lovely and big and you can create a whole flock of him too.

00:24.330 --> 00:26.400
But let's just work with one at a time.

00:26.760 --> 00:34.410
Now that he is in here, he needs to be set up as a nav mesh agent to go onto the nav mesh, just like

00:34.410 --> 00:35.380
our little chompers.

00:35.400 --> 00:41.670
So what I'm going to do is just leave this as a quick challenge for you to put all of that together.

00:41.850 --> 00:43.010
Pause the video now.

00:43.020 --> 00:43.630
Go do that.

00:43.650 --> 00:46.920
When we come back, I'll step you through how to do that again.

00:47.400 --> 00:47.870
Okay.

00:47.880 --> 00:48.880
How did you go with that?

00:48.900 --> 00:54.150
Well, big chopper needs to be made into a nav mesh agent so we can add that there.

00:54.150 --> 00:59.580
Now, our nav mesh collider capsule or whatever you want to call it.

00:59.730 --> 01:02.640
It's probably not quite the right size for him.

01:02.640 --> 01:10.950
Let's just move over a little bit closer so we can bring down the height down to about there.

01:10.950 --> 01:15.170
And we might actually just make his radius a little bit bigger because he is bigger.

01:15.180 --> 01:21.030
So let's just make that point seven and I've got 1.14.

01:21.090 --> 01:22.800
Okay, that'll do for now.

01:23.430 --> 01:27.150
The other thing that he needs is the R script as well.

01:27.150 --> 01:29.000
So let's just drag that on there.

01:29.010 --> 01:32.850
Now he has the chopper animator on there.

01:32.850 --> 01:35.190
So that's going to work with your script.

01:36.150 --> 01:44.400
And of course, don't forget to tag him as an A.I. so that our agent manager will send through the clicks

01:44.400 --> 01:45.090
to him.

01:45.120 --> 01:45.600
Okay.

01:45.600 --> 01:50.280
So we can press play and have a look at his behaviour as well.

01:51.150 --> 01:58.740
So off he goes with the other guys now because he's bigger, it might make sense that he actually moves

01:58.740 --> 01:59.670
a little bit slower.

01:59.670 --> 02:05.550
So if we go into big chopper and have a look at his nav mesh agent, you can see that there's other

02:05.550 --> 02:08.250
settings, especially this steering stuff here.

02:08.250 --> 02:15.080
So he's got like a forward speed of 3.5, an angular speed of 120.

02:15.090 --> 02:18.000
Now the angular speed is how fast he's going to turn around.

02:18.000 --> 02:24.390
So if you want him to turn around slower and to move slower, let's let's put it up to he's going to

02:24.390 --> 02:30.450
be quite slow and let's put the angular speed down at 100, the acceleration.

02:30.600 --> 02:32.160
He's going to accelerate it.

02:32.160 --> 02:32.790
Eight.

02:33.180 --> 02:38.550
In fact, you could make him super speedy, but have his acceleration really, really low.

02:38.550 --> 02:40.710
So once he did get up to speed, he'd be really fast.

02:40.710 --> 02:46.740
But if he was going really fast with a slow turning speed, he'd be a bit hard on the corners anyway.

02:46.740 --> 02:48.370
So you can play around with those.

02:48.390 --> 02:52.830
Let's now just have a look at him at least going slower and turning slower.

02:53.220 --> 02:54.670
Okay, we're ready to go.

02:54.690 --> 02:58.940
So the other little pink guys see how they're much faster than he is.

02:58.950 --> 03:01.020
He's just kind of lumbering along there.

03:03.110 --> 03:09.320
He's not too bad at turning around, but they will overtake him and notice that when they do overtake

03:09.320 --> 03:11.600
him that they will just go round him.

03:11.810 --> 03:17.030
So you have all that behaviour just built in by the fact that there's the collisions for the agents

03:17.030 --> 03:17.870
going on.

03:21.960 --> 03:22.410
Okay.

03:22.410 --> 03:25.470
So this is looking great and we've really hardly done anything.

03:25.470 --> 03:29.790
And thanks to the mesh agents, that's all built in with unity.

03:30.900 --> 03:35.970
Okay, let's find somewhere that we want the pink guys to go.

03:36.000 --> 03:38.610
But for big chopper to not go.

03:38.820 --> 03:45.210
We've got this rock that we were looking at earlier, which isn't navigable at the moment because of

03:45.210 --> 03:47.340
the slope that we've set on there.

03:47.490 --> 03:56.910
So let's go back and what are we going to do in our navigation here is actually make sure that we put

03:56.910 --> 03:58.770
this slope down.

03:58.770 --> 04:05.280
So let's put the slope down to a bit lower.

04:05.670 --> 04:09.690
We'll go back to bake and then bake that again.

04:10.080 --> 04:14.370
We want to get our blue going over the top of this guy here.

04:14.610 --> 04:20.790
Might have come up a bit higher and maybe just a little bit more.

04:21.840 --> 04:22.170
Okay.

04:22.170 --> 04:27.930
So with that going over the top, let's just make sure that they can get up and over that.

04:28.260 --> 04:28.590
Yeah.

04:28.620 --> 04:28.830
Okay.

04:28.830 --> 04:31.650
So currently they can all get up and over to that.

04:31.920 --> 04:37.470
We want to restrict this to be workable only for the pink guys.

04:37.560 --> 04:39.240
So you can select it.

04:39.240 --> 04:45.510
Now, if we go into our object here, we've got these different walkable areas.

04:45.840 --> 04:52.170
So when we bake, we're actually baking walkable, got not walkable and things that you can jump over

04:52.170 --> 04:52.680
as well.

04:52.680 --> 04:54.640
But we're not walking with jump at the moment.

04:54.660 --> 05:02.730
If we go back to our areas, we can create a user three area of, let's say, rock.

05:03.780 --> 05:06.090
Okay, so it's going to be pink.

05:06.180 --> 05:09.180
Now we want to sit this particular rock.

05:09.180 --> 05:15.390
So if we select it, which is Boulder one and come over into object, we're going to make sure that

05:15.390 --> 05:26.670
you've got Boulder One selected there and we will go from walkable to rock for its navigation area.

05:26.880 --> 05:27.120
Okay.

05:27.120 --> 05:32.400
Now, when we go to bake and bake it, it's going to be pink.

05:33.300 --> 05:34.530
So we've got walkable.

05:34.590 --> 05:37.680
And then we have this pink, which is the boulder.

05:38.550 --> 05:43.570
With that, we can set that the pink guys are allowed to go there and chomp a cart.

05:43.590 --> 05:47.190
So if we just go to the pink guys, they're allowed to go everywhere.

05:47.190 --> 05:48.690
But how do they know that?

05:48.690 --> 05:55.650
Well, by default, in the inspector for the nav mesh agent, if we come down to the bottom of the nav

05:55.650 --> 06:00.000
mesh agent, there's an area mask and see how you've got everything down here.

06:00.000 --> 06:03.900
And it's actually shows you where they're allowed to walk.

06:05.220 --> 06:13.980
If you want to make sure that big chopper is not going to go on the rock area, then you would select

06:14.310 --> 06:21.900
Big Chopper and you're going to come down to his nav mesh agent and turn off the rock.

06:22.350 --> 06:27.840
So if it he can go and navigate everything else except that bit there.

06:28.200 --> 06:32.100
Okay, so let's now select play.

06:32.340 --> 06:39.870
And if I click a position on the rock, these guys are all going to go up and get up on top of the rock

06:39.870 --> 06:42.090
or as much as that they can fit there.

06:42.270 --> 06:45.050
But he can't, so he's not going to.

06:45.360 --> 06:51.030
And if I click over here, these guys will all get off trying to get them to take a shortcut over the

06:51.030 --> 06:51.600
top of the rock.

06:51.600 --> 06:58.440
So I'll click over here and some of them do on that walkable area, whereas he's just not able to because

06:58.740 --> 07:02.790
he's too big so these guys can get back up there again and.

07:04.060 --> 07:05.300
He won't be able to.

07:05.320 --> 07:10.420
So that's one way that you can restrict where he can go and where they can go.

07:10.420 --> 07:14.560
And you can also do the opposite for them as well.

07:14.590 --> 07:18.160
So what I'm going to do is give you a bit of a challenge.

07:18.160 --> 07:24.490
Let's find a spot in our map where we want Choppa to be able to get to.

07:24.490 --> 07:26.440
But the pink guy's not.

07:26.800 --> 07:32.230
Okay, so let's say this rock here, let's make this rock that.

07:32.230 --> 07:36.290
It's alright for Chopper to go up and get on top of it and navigate to it.

07:36.310 --> 07:39.640
Now if we go to our nav mesh just to make sure that they can all get up there anyway.

07:39.640 --> 07:40.030
Yep.

07:40.090 --> 07:44.620
Let's make that his domain that he can only get up there and they can't get there.

07:44.620 --> 07:47.590
So pause the video now, give it a go.

07:47.590 --> 07:50.230
And when we come back, I'll go through that with you.

07:52.000 --> 07:52.510
All right.

07:52.510 --> 07:53.600
Welcome back.

07:53.620 --> 07:55.190
How did you go with that?

07:55.210 --> 08:00.160
Well, the first thing we need in our nav mesh system is an area.

08:00.160 --> 08:07.200
So let's go into user for let's call this big chompers rock.

08:07.210 --> 08:09.520
I won't put a quote in next.

08:09.520 --> 08:10.870
I don't know whether that will work or not.

08:10.870 --> 08:12.820
So let's put big chompers rock.

08:12.820 --> 08:18.910
Let's go over into our bake setting, which we're not too interested in at the moment.

08:18.910 --> 08:23.800
What we've got to do with this big rock is actually just select it, okay?

08:23.980 --> 08:29.950
And then we have to make sure that it is set to that particular area.

08:29.950 --> 08:38.260
So we go to the object tab, make sure that Rock zero one is selected navigation area to Big Chompers

08:38.260 --> 08:38.860
Rock.

08:39.340 --> 08:42.430
Now if we come back to Bake, we can click bait.

08:42.430 --> 08:47.410
We don't have to change the slope or anything because we already know that these guys can get up there.

08:47.410 --> 08:50.440
You'll see now that it's a green area.

08:51.610 --> 08:59.470
Okay, now before we let these guys go about their business, we're going to select them and make sure

08:59.470 --> 09:02.170
that their area mask is correct.

09:02.320 --> 09:08.530
So once you've changed it kind of from everything, then you need to check all these individually.

09:08.530 --> 09:13.450
Now make sure that Big Chopper has big chopper rock selected for him.

09:13.540 --> 09:23.800
And then if you select and a command or control shift of all these other little guys and let's select

09:24.130 --> 09:27.220
Chopper because we don't want him there, but we do want this other one.

09:27.430 --> 09:34.480
Let's go to the area mask and make sure that the big Chompers rock is not selected, but everything

09:34.480 --> 09:36.310
else is okay.

09:36.310 --> 09:41.770
So now just move your camera if you can't see the big rock when you press play.

09:41.770 --> 09:44.590
But let's see how this goes in play mode.

09:44.590 --> 09:50.050
So if we select up here on the Rock, everybody's going to try and get over here and they will get as

09:50.050 --> 09:53.560
close as they can, but they can't get up there.

09:53.560 --> 09:54.250
They're not allowed.

09:54.250 --> 09:55.990
But can big chomping it up there.

09:55.990 --> 09:59.620
Yes, he can because he can go in that green area.

09:59.620 --> 10:01.300
And so there we go.

10:01.300 --> 10:02.350
He's up there now.

10:03.500 --> 10:03.890
Okay.

10:03.890 --> 10:10.580
So that is how you can restrict where agents can and where agents can't go.
