In this lecture, we're going to start putting the GOP's system into practice.
So what I want you to do is create a new unity project and bring in the start a package that's attached
to this lecture you're going to find when you open up the basic working hospital scene that's in there,
a very simple little hospital which looks like this.
Okay, now what you're going to find with this hospital is it has a nav mesh on it and we're going to
use the nave mesh to get our agents to move around between their different goals.
Over in the Inspector, I've also got my navigation tab open.
Now, if you don't have that, you can go to Window I and navigation to bring that up.
If you add new objects or move things around, create new walls and that, make sure you'll always come
back into the navigation and click on Bake so that those things will be taken into consideration.
And if you click on something in here like this wall or just grab hold of that, and over in the inspector
you'll see that it's actually set to a navigation static.
If I bring that in and everything that you want to be excluded from the nav mesh or to be a barrier
in the navigation has to be a navigation static.
So everything you can see in here, the plants included, and these cubicles at the back are all navigation
static objects.
Okay.
So we need some agents.
What we're going to do in this simulation is a very simple little hospital.
Patients going to come in.
They're going to come in and get registered at the reception desk, which is just over here.
Then they're going to go into the waiting room over here.
We'll have some nurses.
The nurses will stay over in the staff area if they need a break.
Otherwise, they're going to come out and get a patient.
So patients will come in, register, go in the waiting area, wait for a nurse.
The nurse will pick them up and assign them to a cubicle.
They get treated and then they'll go home.
The nurse will be freed to get another patient or to go and take a break.
The first thing we'll need are some agents who will be our go agents that have some goals to achieve.
If you open up the prefab folder, you're going to find some medical stuff and a patient want you to
get hold of your patient and drag and drop it into the scene and just lift it up so it's sitting on
the ground.
Okay.
This patient is just a model, so he doesn't have a nav mesh on there.
So let's just get in a little closer so he can see what we're doing on this patient.
Why not make sure he's lifted up so he doesn't go through the ground?
Okay, so the first thing, go over to the inspector, add a component and add a nav mesh agent.
Now, when you add that, it's going to center itself in the middle of his body down there and go above.
And if we just move over a bit closer, you'll be able to see that a little bit more clearly.
So we need to move it down over in the settings for the navigation agent.
You've got a base offset and you're going to just slide that until it hits the ground.
Now we want to make sure that it's near the bottom of the character.
So he's going to be about unit size.
And you shouldn't have to change the size of your nav mesh for it to fit the character quite nicely.
Okay.
So that's the patient.
Now, you'll also need to do that with the nurse that will be using in this tutorial.
So just drag the nurse out, bring the nurse up a little bit, and then over in the inspector again
we add a nav mesh agent and we want to set the offset.
Now the patient, we already set the offset and it's at 1.05, let's just make that one nice rounded
one.
So we know if we go back to the nurse and we change her offset to one, then it's going to come down
and fit her quite nicely.
Now, throughout the simulation, the agents need to know where the waypoints are that are going to
be sitting on this nav mesh so that they can move about the patient, which is this little guy here.
He's going to come in through the door.
So they'll need to be a waypoint at the door.
We're going to have them register.
They'll need to be another waypoint there and then one in the waiting area.
The other waypoints they also need to know about are the cubicles and then also a waypoint outside of
the map to get home after they've been treated.
The nurse will need to know about the nurses waiting area which is in here, the waiting area where
the patients are going to be waiting, and also the cubicles that are up here so that they can assign
patients to cubicles.
If you go over into the hierarchy, you'll see that I've got game objects in all of those positions.
So the very first thing on the list, starting at waiting area is in the waiting area.
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
a cube that has been flattened out.
Now, let me put that back to zero in the why.
So it's kind of sitting on the floor.
The waypoint itself is that position there, not the actual size of the cube that I created.
But when I started this, I was just planning out where these areas would be.
It's very important that if you do use a cube or something as your waypoint, that you make sure that
you don't have the collider turned on.
If you want to see where it is and that's fine, turn on the mesh renderer so that you can see where
you've put everything.
But afterwards, turn that off.
Now, the reason you don't want the Box Collider on is that the patient in trying to get to this particular
waypoint will hit the outside of the box collider because they do respond to physics and never be able
to get to the destination which is here.
Now I've got another cube that I put over in the staff lounge over in this area and again turned all
of the rendering and colliding off.
There's also a door.
Now the door position is in the center of this doorway here.
Now, I guess you don't really need it, because the pathfinding, if you were to go to the actual reception,
would find its way through here anyway because it is the only gap to get into the hospital.
But when I started testing this, I actually didn't have any walls, so I was just making sure it went
through there.
So I've still got it there and we're still going to use it as one of our destinations.
The cubicles themselves are also destinations, as I said, and they're all just sitting there and the
reception desk now so our agents can figure out where all these objects are when they get instantiated.
I have put tags on them.
So if you have a look at the waiting area, you'll see that it's tagged with waiting area, the staff
lounge, lounge, the door with door and etc. And if we go and have a look at those tags I created,
you can see how they're spelt and how they're spelt is very important because you need to use the string
of the tag in order to match it and find it for your agents.
Now, if you remember back to the previous video where we were talking about all the different actions
that our soap agents can take, they're all matched together like dominoes, using preconditions and
effect.
They will also be string values that we have to match, and therefore our spelling and capitalisation
needs to be exactly the same for each one.
And therefore we really should sit down and plan it out on paper or in diagrammatic form before we move
ahead, just to make sure when we do go and type everything in that we know what things are called and
we know which strings have to match with what other strings.
So we'll come back in the next video and actually start planning out the actions for each of our agents
and work out what is going to be needed for them.