if we change this part of the previous code
//move towards the player
myTransform.position += myTransform.forward * moveSpeed * Time.deltaTime;
to:
//move towards the player if
not too close
if ( ( myTransform.position -
target.position ).sqrMagnitude > 4F )
{
{
myTransform.position +=
myTransform.forward * moveSpeed * Time.deltaTime;
}
it should only move towards the player if the player is a certain distance away so it should in theory stop moving all together if it is so many units close to the player.
I have put this code in, and so far so good. It is working : )
ReplyDelete