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 I'm going to do now is give this to you as a challenge to right.
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 pose a 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 at what we need to do to create and evade.
So, first of all, let's create the outline for our evade so evade.
And you could almost grab all of what's in pursuit, put it into here and change the seat into flames.
Now, I'm not going to do that.
What I'm going to do instead after I just put a down here in the update so that it will run, it is
only take the necessary components from it.
So when we're running away, we're only really concerned about running away from the predicted position,
even if the agent is heading towards us.
So let's just grab this value for our target, DPR and these two down the bottom, which is what we
started with when we created our very first pursue.
OK, so that we had this now in here, I'm just going to change this, seek to flee.
So we're actually going away in the opposite direction to what we were doing.
OK, so how did you go?
Did you get that?
Let's just save it and have a look at what we get.
Let's go back into here and press play, and now we're going to have an agent that's going to evade.
So if I go over here, he's going to start turning away from me.
Try and come back this way, he's going to keep inviting.
OK, so nice and simple, if you lift those if statements in with the angles and that it would be interesting
to see what you came up with it and it probably still works just fine, but is now checking for angles.
But depending on what angles you're using, you might get some odd behaviors where the cop could be
heading towards the robber and the robber could decide that he's going to go straight past the cop to
evade in the sort of in the opposite direction, which would be a bad idea for him to come anywhere
near the cop, which is not what you want.
So back in our code, again, this is all that you need to have in an avowed.
As I said, it's the opposite of pursuit.