Welcome back to this series on NAV measures.
So far we've created a flock of chompers.
Now, if you have a look in the assets folder, I've also added a big jumper prefab in there so you
can bring him in.
He's lovely and big and you can create a whole flock of him too.
But let's just work with one at a time.
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
our little chompers.
So what I'm going to do is just leave this as a quick challenge for you to put all of that together.
Pause the video now.
Go do that.
When we come back, I'll step you through how to do that again.
Okay.
How did you go with that?
Well, big chopper needs to be made into a nav mesh agent so we can add that there.
Now, our nav mesh collider capsule or whatever you want to call it.
It's probably not quite the right size for him.
Let's just move over a little bit closer so we can bring down the height down to about there.
And we might actually just make his radius a little bit bigger because he is bigger.
So let's just make that point seven and I've got 1.14.
Okay, that'll do for now.
The other thing that he needs is the R script as well.
So let's just drag that on there.
Now he has the chopper animator on there.
So that's going to work with your script.
And of course, don't forget to tag him as an A.I. so that our agent manager will send through the clicks
to him.
Okay.
So we can press play and have a look at his behaviour as well.
So off he goes with the other guys now because he's bigger, it might make sense that he actually moves
a little bit slower.
So if we go into big chopper and have a look at his nav mesh agent, you can see that there's other
settings, especially this steering stuff here.
So he's got like a forward speed of 3.5, an angular speed of 120.
Now the angular speed is how fast he's going to turn around.
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
be quite slow and let's put the angular speed down at 100, the acceleration.
He's going to accelerate it.
Eight.
In fact, you could make him super speedy, but have his acceleration really, really low.
So once he did get up to speed, he'd be really fast.
But if he was going really fast with a slow turning speed, he'd be a bit hard on the corners anyway.
So you can play around with those.
Let's now just have a look at him at least going slower and turning slower.
Okay, we're ready to go.
So the other little pink guys see how they're much faster than he is.
He's just kind of lumbering along there.
He's not too bad at turning around, but they will overtake him and notice that when they do overtake
him that they will just go round him.
So you have all that behaviour just built in by the fact that there's the collisions for the agents
going on.
Okay.
So this is looking great and we've really hardly done anything.
And thanks to the mesh agents, that's all built in with unity.
Okay, let's find somewhere that we want the pink guys to go.
But for big chopper to not go.
We've got this rock that we were looking at earlier, which isn't navigable at the moment because of
the slope that we've set on there.
So let's go back and what are we going to do in our navigation here is actually make sure that we put
this slope down.
So let's put the slope down to a bit lower.
We'll go back to bake and then bake that again.
We want to get our blue going over the top of this guy here.
Might have come up a bit higher and maybe just a little bit more.
Okay.
So with that going over the top, let's just make sure that they can get up and over that.
Yeah.
Okay.
So currently they can all get up and over to that.
We want to restrict this to be workable only for the pink guys.
So you can select it.
Now, if we go into our object here, we've got these different walkable areas.
So when we bake, we're actually baking walkable, got not walkable and things that you can jump over
as well.
But we're not walking with jump at the moment.
If we go back to our areas, we can create a user three area of, let's say, rock.
Okay, so it's going to be pink.
Now we want to sit this particular rock.
So if we select it, which is Boulder one and come over into object, we're going to make sure that
you've got Boulder One selected there and we will go from walkable to rock for its navigation area.
Okay.
Now, when we go to bake and bake it, it's going to be pink.
So we've got walkable.
And then we have this pink, which is the boulder.
With that, we can set that the pink guys are allowed to go there and chomp a cart.
So if we just go to the pink guys, they're allowed to go everywhere.
But how do they know that?
Well, by default, in the inspector for the nav mesh agent, if we come down to the bottom of the nav
mesh agent, there's an area mask and see how you've got everything down here.
And it's actually shows you where they're allowed to walk.
If you want to make sure that big chopper is not going to go on the rock area, then you would select
Big Chopper and you're going to come down to his nav mesh agent and turn off the rock.
So if it he can go and navigate everything else except that bit there.
Okay, so let's now select play.
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
or as much as that they can fit there.
But he can't, so he's not going to.
And if I click over here, these guys will all get off trying to get them to take a shortcut over the
top of the rock.
So I'll click over here and some of them do on that walkable area, whereas he's just not able to because
he's too big so these guys can get back up there again and.
He won't be able to.
So that's one way that you can restrict where he can go and where they can go.
And you can also do the opposite for them as well.
So what I'm going to do is give you a bit of a challenge.
Let's find a spot in our map where we want Choppa to be able to get to.
But the pink guy's not.
Okay, so let's say this rock here, let's make this rock that.
It's alright for Chopper to go up and get on top of it and navigate to it.
Now if we go to our nav mesh just to make sure that they can all get up there anyway.
Yep.
Let's make that his domain that he can only get up there and they can't get there.
So pause the video now, give it a go.
And when we come back, I'll go through that with you.
All right.
Welcome back.
How did you go with that?
Well, the first thing we need in our nav mesh system is an area.
So let's go into user for let's call this big chompers rock.
I won't put a quote in next.
I don't know whether that will work or not.
So let's put big chompers rock.
Let's go over into our bake setting, which we're not too interested in at the moment.
What we've got to do with this big rock is actually just select it, okay?
And then we have to make sure that it is set to that particular area.
So we go to the object tab, make sure that Rock zero one is selected navigation area to Big Chompers
Rock.
Now if we come back to Bake, we can click bait.
We don't have to change the slope or anything because we already know that these guys can get up there.
You'll see now that it's a green area.
Okay, now before we let these guys go about their business, we're going to select them and make sure
that their area mask is correct.
So once you've changed it kind of from everything, then you need to check all these individually.
Now make sure that Big Chopper has big chopper rock selected for him.
And then if you select and a command or control shift of all these other little guys and let's select
Chopper because we don't want him there, but we do want this other one.
Let's go to the area mask and make sure that the big Chompers rock is not selected, but everything
else is okay.
So now just move your camera if you can't see the big rock when you press play.
But let's see how this goes in play mode.
So if we select up here on the Rock, everybody's going to try and get over here and they will get as
close as they can, but they can't get up there.
They're not allowed.
But can big chomping it up there.
Yes, he can because he can go in that green area.
And so there we go.
He's up there now.
Okay.
So that is how you can restrict where agents can and where agents can't go.