Now we're going to have a look at the behavior called Evade.
Evade is pretty much exactly the same as pursuit, except that it's going away from a predicted position
instead of going towards it.
So instead of seeking a predicted position, we actually want to flee from it.
So what I'm going to do now is give this to you as a challenge to write the evade method.
Given what you already know about pursuit and seeking, you should be able to put together and evade
with a fleeing.
So pause the video now.
And when we come back, I'll show you how to put it into action.
All right.
How did you go with that?
Let's have a look and what we need to do to create an evade.
Now, before we begin, I'm actually going to get rid of this get component thing that's going on in
here because, of course, that's going to slow things down.
So now that you know about the drive script and the current speed in there, we can actually just copy
this.
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
it drive script like that, and then we can actually say these equals that drive script there, then
we can use these to get the current speed.
So if we come back down into our pursuit, we're actually using it.
We can just replace that with DS and we can replace that with DS and anywhere else that it is in your
code.
I think that's the only two positions at the moment, right?
So let's go and create our VADE code.
So from the pursuit we can grab these two lines here and we'll put that in there.
And then we also want our look ahead value that we're calculating and we're going to grab this seek
line as well.
Now instead of seek, we're actually going to use Flee in there instead.
Okay, so that's our evade now down in the update.
Just put that in there as well like that.
Okay.
So let's save this and go back into unity and give this to go to see if our robber is going to evade
us.
So let's press play and off he goes.
Now, if I try to go this way, I should be able to sort of heading off or I try to head him off.
He'll actually turn in a completely different direction rather than just going straight ahead from us.
You can see he's actually doing an evade in there and that's pretty much it.
That's how you create an evade.
When we come back in the next lecture, we'll work on a wandering behavior.