WEBVTT

00:06.450 --> 00:09.390
We're going to begin this video with a challenge.

00:09.390 --> 00:17.280
What I would like you to do is to add a new goal to the patient so that the patient goes home after

00:17.280 --> 00:20.520
he spent his treatment time in the cubicle.

00:20.640 --> 00:27.240
Now, home, if you remember, right back to the beginning, is actually a location in the map.

00:27.240 --> 00:29.280
So there's an item called home here.

00:29.280 --> 00:31.350
It has a home tag.

00:31.350 --> 00:38.370
And if we click on it and just zoom out and have a bit of a look where that home is, you can see that

00:38.370 --> 00:40.950
it's a position over here.

00:41.460 --> 00:41.640
Okay.

00:41.820 --> 00:48.000
So that will just get the agent to walk out of the hospital as though he's going home.

00:48.630 --> 00:55.740
So currently, when our patient gets to the cubicle with the nurse, if we just have a look at our patient

00:55.740 --> 01:02.530
code and come down to our get treatment, this is the last stage.

01:02.530 --> 01:04.920
So it's going to stay there and not go anywhere.

01:04.920 --> 01:08.310
Now, there's no duration set up currently for our get treated.

01:08.310 --> 01:14.970
So if you do want to give that say like a five second duration, so it does take a bit of time for the

01:14.970 --> 01:16.560
treatment to occur.

01:16.590 --> 01:21.570
Then you want to figure out how to get him to leave and go home.

01:21.840 --> 01:24.720
So this is the challenge for you.

01:24.720 --> 01:26.010
Pause the video now.

01:26.010 --> 01:26.580
Give it a go.

01:26.580 --> 01:29.160
When we come back, I'll step through that with you.

01:30.510 --> 01:30.960
Okay.

01:30.960 --> 01:32.940
So how did you go with that?

01:32.940 --> 01:36.870
Well, the first thing you need to do is actually create another action.

01:36.870 --> 01:39.570
So we want to pick a script to duplicate.

01:39.570 --> 01:40.620
That's quite simple.

01:40.980 --> 01:41.790
Go to hospital.

01:41.790 --> 01:43.500
There's not really much going on in there.

01:43.530 --> 01:45.600
Let's duplicate that.

01:45.600 --> 01:48.720
We're going to call it Go Home.

01:49.110 --> 01:55.320
And then you want to open that up and also change the name of the class to go home.

01:55.710 --> 01:57.960
Now, there's really nothing you have to do in this script.

01:58.200 --> 02:00.810
There's no pre perform and there's no post reform.

02:00.810 --> 02:07.470
Everything gets set in the inspector and in fact you probably could just use the same script as go to

02:07.470 --> 02:12.390
hospital and attach that again and just rename the variables in it.

02:12.390 --> 02:16.170
But in this case we've got something separate, so let's just save that.

02:16.170 --> 02:18.150
Now, while we're here, let's go into the patient.

02:18.150 --> 02:23.880
The patient needs to have another goal that is to go home.

02:24.000 --> 02:29.700
Of course, you could have go home after is treated as well.

02:29.700 --> 02:30.840
You could do it that way.

02:30.840 --> 02:35.250
But in this case, I'm just doing it with an extra sub goal.

02:35.430 --> 02:39.240
Okay, so what are we going to do under here is copy this one.

02:40.320 --> 02:41.730
Put it down here.

02:41.730 --> 02:43.230
I call this three.

02:45.100 --> 02:52.750
And in here we will have is home as the goal.

02:53.020 --> 02:54.490
Okay, so save that.

02:54.760 --> 03:00.190
Now let's go back in to Unity and select our patient.

03:00.190 --> 03:08.080
So we're going to go home on to the patient there and let's name it as go home.

03:08.980 --> 03:17.350
The target tag in this case is home and there's no duration, the pre condition.

03:17.350 --> 03:19.570
We're going to add in a precondition one here.

03:19.570 --> 03:22.510
And we don't want the patient to actually go home until they're cured.

03:22.510 --> 03:31.000
So I put is cured here as the pre condition the after effect which has to match the goal.

03:31.930 --> 03:36.580
We want one of those and it's going to be is home.

03:37.460 --> 03:37.790
Okay.

03:37.790 --> 03:40.260
So where do we put is cured?

03:40.280 --> 03:44.900
Well, it's not going to be a world state because it has to apply to the actual patient.

03:45.230 --> 03:52.790
That means that whatever action is happening to cure the patient will need to inject that belief into

03:52.790 --> 03:59.730
the patient so the patient is getting cured in its get treated script.

03:59.750 --> 04:02.300
So if we go into get treated.

04:03.600 --> 04:08.860
You can see that I've already added this in here and all you've got to do is just add beliefs, dot

04:08.910 --> 04:10.260
modify state.

04:11.020 --> 04:20.890
Is cured and that will go into the agents beliefs and then allow that extra task or action to execute.

04:21.190 --> 04:23.800
Now let's go back into Unity to play it.

04:24.040 --> 04:27.280
Actually, before I do, let's just go into G World.

04:27.280 --> 04:32.500
And I just wanted to show you a little bit of code that I've put in here to make things run a hell of

04:32.500 --> 04:38.950
a lot faster so you could speed up the agents movement, but that's going to give you inaccurate sort

04:38.950 --> 04:41.980
of, I guess, movement and physics on the nav mesh.

04:41.980 --> 04:44.920
Instead, you just want to speed the entire simulation up.

04:44.920 --> 04:50.680
So you can do that by changing the time scale somewhere within your code that runs like first up.

04:50.680 --> 04:55.990
That's why I've got it inside of the instantiate for the G world and set it to five.

04:55.990 --> 04:58.510
So it's going to do five times of speed.

04:58.510 --> 04:59.770
Okay, so save that.

04:59.770 --> 05:07.540
Now, with all of that done, we can now check out our full plan for our patient.

05:07.660 --> 05:08.080
All right.

05:08.080 --> 05:14.320
So if you've been using the patient like I have and turning it on and off and then make sure you also

05:14.320 --> 05:18.640
override it while it is turned on and then you can turn it off.

05:18.880 --> 05:20.200
I'm going to leave this guy on now.

05:20.200 --> 05:23.620
I've just moved him outside so he can be the first guy that comes in.

05:23.620 --> 05:30.220
Let's have a look at how this runs and what does the nurse do when the patient goes home.

05:30.220 --> 05:31.150
So let's have a look.

05:31.150 --> 05:37.540
They coming in, the nurse gets the patient, go over to the cubicle, he goes home.

05:37.540 --> 05:41.890
She's like thinking about picking up someone else, which she does.

05:41.890 --> 05:43.750
She goes and gets him because that's her goal.

05:43.750 --> 05:44.290
That's what she does.

05:44.290 --> 05:45.490
She just wants to treat a patient.

05:45.490 --> 05:51.640
As long as there's a patient available, she's just going to keep running that goal over and over again.

05:51.640 --> 05:54.670
And as you can see, she's doing a great job of it.

05:55.150 --> 05:56.230
Okay.

05:56.260 --> 05:59.280
So she's getting a bit overwhelmed.

05:59.290 --> 06:06.220
This has been a introduction to goal orientated action planning and I'm sure by now you can see the

06:06.220 --> 06:08.410
power that is in it.

06:08.410 --> 06:15.700
If you're very interested in continuing on and learning more about this system and building a more interactive

06:15.700 --> 06:21.850
hospital like the one you can see here on the screen, then please do visit my learning website where

06:21.850 --> 06:26.410
you can interact with other students who are also building the same simulation.
