WEBVTT

00:02.800 --> 00:07.250
In this lecture, we're going to start putting the GOP's system into practice.

00:07.270 --> 00:13.780
So what I want you to do is create a new unity project and bring in the start a package that's attached

00:13.780 --> 00:21.190
to this lecture you're going to find when you open up the basic working hospital scene that's in there,

00:21.310 --> 00:25.840
a very simple little hospital which looks like this.

00:26.700 --> 00:33.610
Okay, now what you're going to find with this hospital is it has a nav mesh on it and we're going to

00:33.610 --> 00:38.590
use the nave mesh to get our agents to move around between their different goals.

00:38.740 --> 00:43.840
Over in the Inspector, I've also got my navigation tab open.

00:43.840 --> 00:51.190
Now, if you don't have that, you can go to Window I and navigation to bring that up.

00:51.700 --> 00:57.760
If you add new objects or move things around, create new walls and that, make sure you'll always come

00:57.760 --> 01:03.850
back into the navigation and click on Bake so that those things will be taken into consideration.

01:03.850 --> 01:11.950
And if you click on something in here like this wall or just grab hold of that, and over in the inspector

01:11.950 --> 01:17.290
you'll see that it's actually set to a navigation static.

01:17.290 --> 01:24.850
If I bring that in and everything that you want to be excluded from the nav mesh or to be a barrier

01:24.850 --> 01:27.070
in the navigation has to be a navigation static.

01:27.070 --> 01:34.480
So everything you can see in here, the plants included, and these cubicles at the back are all navigation

01:34.480 --> 01:36.190
static objects.

01:37.110 --> 01:37.710
Okay.

01:37.710 --> 01:40.530
So we need some agents.

01:40.530 --> 01:44.280
What we're going to do in this simulation is a very simple little hospital.

01:44.280 --> 01:46.500
Patients going to come in.

01:46.530 --> 01:51.420
They're going to come in and get registered at the reception desk, which is just over here.

01:51.510 --> 01:54.660
Then they're going to go into the waiting room over here.

01:54.900 --> 01:56.500
We'll have some nurses.

01:56.520 --> 02:01.700
The nurses will stay over in the staff area if they need a break.

02:01.710 --> 02:05.270
Otherwise, they're going to come out and get a patient.

02:05.280 --> 02:09.570
So patients will come in, register, go in the waiting area, wait for a nurse.

02:09.570 --> 02:12.860
The nurse will pick them up and assign them to a cubicle.

02:12.870 --> 02:14.930
They get treated and then they'll go home.

02:14.940 --> 02:19.980
The nurse will be freed to get another patient or to go and take a break.

02:21.150 --> 02:27.810
The first thing we'll need are some agents who will be our go agents that have some goals to achieve.

02:27.840 --> 02:35.040
If you open up the prefab folder, you're going to find some medical stuff and a patient want you to

02:35.040 --> 02:43.470
get hold of your patient and drag and drop it into the scene and just lift it up so it's sitting on

02:43.470 --> 02:44.550
the ground.

02:44.730 --> 02:44.940
Okay.

02:44.950 --> 02:50.820
This patient is just a model, so he doesn't have a nav mesh on there.

02:50.820 --> 02:55.830
So let's just get in a little closer so he can see what we're doing on this patient.

02:56.370 --> 03:00.090
Why not make sure he's lifted up so he doesn't go through the ground?

03:00.120 --> 03:06.840
Okay, so the first thing, go over to the inspector, add a component and add a nav mesh agent.

03:06.870 --> 03:14.370
Now, when you add that, it's going to center itself in the middle of his body down there and go above.

03:14.520 --> 03:20.760
And if we just move over a bit closer, you'll be able to see that a little bit more clearly.

03:20.760 --> 03:26.650
So we need to move it down over in the settings for the navigation agent.

03:26.670 --> 03:33.570
You've got a base offset and you're going to just slide that until it hits the ground.

03:33.600 --> 03:37.980
Now we want to make sure that it's near the bottom of the character.

03:37.980 --> 03:42.360
So he's going to be about unit size.

03:42.360 --> 03:50.160
And you shouldn't have to change the size of your nav mesh for it to fit the character quite nicely.

03:51.170 --> 03:51.650
Okay.

03:51.650 --> 03:53.820
So that's the patient.

03:53.840 --> 03:58.820
Now, you'll also need to do that with the nurse that will be using in this tutorial.

03:58.820 --> 04:06.320
So just drag the nurse out, bring the nurse up a little bit, and then over in the inspector again

04:06.320 --> 04:10.040
we add a nav mesh agent and we want to set the offset.

04:10.040 --> 04:17.300
Now the patient, we already set the offset and it's at 1.05, let's just make that one nice rounded

04:17.300 --> 04:17.900
one.

04:17.900 --> 04:24.380
So we know if we go back to the nurse and we change her offset to one, then it's going to come down

04:24.380 --> 04:27.200
and fit her quite nicely.

04:28.820 --> 04:34.010
Now, throughout the simulation, the agents need to know where the waypoints are that are going to

04:34.010 --> 04:41.690
be sitting on this nav mesh so that they can move about the patient, which is this little guy here.

04:41.720 --> 04:44.330
He's going to come in through the door.

04:44.330 --> 04:46.910
So they'll need to be a waypoint at the door.

04:46.940 --> 04:48.700
We're going to have them register.

04:48.710 --> 04:52.790
They'll need to be another waypoint there and then one in the waiting area.

04:52.910 --> 04:59.810
The other waypoints they also need to know about are the cubicles and then also a waypoint outside of

04:59.810 --> 05:02.970
the map to get home after they've been treated.

05:02.990 --> 05:09.410
The nurse will need to know about the nurses waiting area which is in here, the waiting area where

05:09.410 --> 05:16.250
the patients are going to be waiting, and also the cubicles that are up here so that they can assign

05:16.250 --> 05:18.080
patients to cubicles.

05:18.770 --> 05:24.890
If you go over into the hierarchy, you'll see that I've got game objects in all of those positions.

05:24.890 --> 05:31.880
So the very first thing on the list, starting at waiting area is in the waiting area.

05:31.880 --> 05:41.000
And if we just go and see where that is just here, you'll see if I move it right up that it is actually

05:41.000 --> 05:44.850
a cube that has been flattened out.

05:44.870 --> 05:47.180
Now, let me put that back to zero in the why.

05:47.180 --> 05:49.430
So it's kind of sitting on the floor.

05:50.420 --> 05:56.960
The waypoint itself is that position there, not the actual size of the cube that I created.

05:56.960 --> 06:02.030
But when I started this, I was just planning out where these areas would be.

06:02.090 --> 06:08.150
It's very important that if you do use a cube or something as your waypoint, that you make sure that

06:08.150 --> 06:10.670
you don't have the collider turned on.

06:10.670 --> 06:17.840
If you want to see where it is and that's fine, turn on the mesh renderer so that you can see where

06:17.960 --> 06:19.070
you've put everything.

06:19.070 --> 06:20.580
But afterwards, turn that off.

06:20.600 --> 06:28.310
Now, the reason you don't want the Box Collider on is that the patient in trying to get to this particular

06:28.310 --> 06:33.890
waypoint will hit the outside of the box collider because they do respond to physics and never be able

06:33.890 --> 06:36.530
to get to the destination which is here.

06:36.740 --> 06:43.790
Now I've got another cube that I put over in the staff lounge over in this area and again turned all

06:43.790 --> 06:46.930
of the rendering and colliding off.

06:46.940 --> 06:48.560
There's also a door.

06:48.590 --> 06:53.810
Now the door position is in the center of this doorway here.

06:53.900 --> 07:00.050
Now, I guess you don't really need it, because the pathfinding, if you were to go to the actual reception,

07:00.050 --> 07:05.430
would find its way through here anyway because it is the only gap to get into the hospital.

07:05.450 --> 07:10.550
But when I started testing this, I actually didn't have any walls, so I was just making sure it went

07:10.550 --> 07:11.240
through there.

07:11.240 --> 07:15.680
So I've still got it there and we're still going to use it as one of our destinations.

07:15.830 --> 07:23.600
The cubicles themselves are also destinations, as I said, and they're all just sitting there and the

07:23.600 --> 07:32.640
reception desk now so our agents can figure out where all these objects are when they get instantiated.

07:32.660 --> 07:34.640
I have put tags on them.

07:34.640 --> 07:40.340
So if you have a look at the waiting area, you'll see that it's tagged with waiting area, the staff

07:40.340 --> 07:49.100
lounge, lounge, the door with door and etc. And if we go and have a look at those tags I created,

07:49.100 --> 07:56.090
you can see how they're spelt and how they're spelt is very important because you need to use the string

07:56.090 --> 08:01.130
of the tag in order to match it and find it for your agents.

08:01.790 --> 08:07.220
Now, if you remember back to the previous video where we were talking about all the different actions

08:07.220 --> 08:13.940
that our soap agents can take, they're all matched together like dominoes, using preconditions and

08:13.940 --> 08:14.780
effect.

08:14.780 --> 08:22.010
They will also be string values that we have to match, and therefore our spelling and capitalisation

08:22.010 --> 08:26.150
needs to be exactly the same for each one.

08:26.390 --> 08:35.240
And therefore we really should sit down and plan it out on paper or in diagrammatic form before we move

08:35.240 --> 08:41.030
ahead, just to make sure when we do go and type everything in that we know what things are called and

08:41.030 --> 08:44.720
we know which strings have to match with what other strings.

08:44.810 --> 08:53.660
So we'll come back in the next video and actually start planning out the actions for each of our agents

08:53.660 --> 08:57.440
and work out what is going to be needed for them.
