WEBVTT

00:04.010 --> 00:07.430
Now we're going to have a look at the behavior called Evade.

00:07.460 --> 00:15.410
Evade is pretty much exactly the same as pursuit, except that it's going away from a predicted position

00:15.410 --> 00:17.530
instead of going towards it.

00:17.540 --> 00:23.090
So instead of seeking a predicted position, we actually want to flee from it.

00:23.420 --> 00:29.870
So what I'm going to do now is give this to you as a challenge to write the evade method.

00:30.080 --> 00:36.890
Given what you already know about pursuit and seeking, you should be able to put together and evade

00:36.890 --> 00:38.690
with a fleeing.

00:39.140 --> 00:40.910
So pause the video now.

00:40.910 --> 00:44.750
And when we come back, I'll show you how to put it into action.

00:45.410 --> 00:45.800
All right.

00:45.800 --> 00:47.000
How did you go with that?

00:47.000 --> 00:51.320
Let's have a look and what we need to do to create an evade.

00:51.890 --> 00:57.620
Now, before we begin, I'm actually going to get rid of this get component thing that's going on in

00:57.620 --> 01:00.380
here because, of course, that's going to slow things down.

01:00.380 --> 01:05.810
So now that you know about the drive script and the current speed in there, we can actually just copy

01:05.810 --> 01:06.710
this.

01:07.880 --> 01:18.800
And what we're going to do up in the start is to put this in here, but we will create a drive and call

01:18.800 --> 01:26.780
it drive script like that, and then we can actually say these equals that drive script there, then

01:26.780 --> 01:29.690
we can use these to get the current speed.

01:29.690 --> 01:33.260
So if we come back down into our pursuit, we're actually using it.

01:33.260 --> 01:44.000
We can just replace that with DS and we can replace that with DS and anywhere else that it is in your

01:44.000 --> 01:44.270
code.

01:44.270 --> 01:47.390
I think that's the only two positions at the moment, right?

01:47.390 --> 01:50.390
So let's go and create our VADE code.

01:50.750 --> 01:56.360
So from the pursuit we can grab these two lines here and we'll put that in there.

01:56.420 --> 02:03.200
And then we also want our look ahead value that we're calculating and we're going to grab this seek

02:03.230 --> 02:04.550
line as well.

02:04.550 --> 02:10.520
Now instead of seek, we're actually going to use Flee in there instead.

02:10.760 --> 02:14.810
Okay, so that's our evade now down in the update.

02:14.810 --> 02:17.600
Just put that in there as well like that.

02:17.630 --> 02:18.040
Okay.

02:18.050 --> 02:26.060
So let's save this and go back into unity and give this to go to see if our robber is going to evade

02:26.060 --> 02:26.660
us.

02:26.870 --> 02:30.830
So let's press play and off he goes.

02:30.830 --> 02:35.570
Now, if I try to go this way, I should be able to sort of heading off or I try to head him off.

02:35.570 --> 02:41.150
He'll actually turn in a completely different direction rather than just going straight ahead from us.

02:41.150 --> 02:47.180
You can see he's actually doing an evade in there and that's pretty much it.

02:47.180 --> 02:49.340
That's how you create an evade.

02:49.640 --> 02:53.570
When we come back in the next lecture, we'll work on a wandering behavior.
