Getting Enemy to Stop

Hello, I have been working on a script that will follow the enemy when at a certain distance, but then stop when I am far enough away. The enemy is currently not moving and I do not know why.

public GameObject Player;
public float WalkDist = 4.0f;

void Start()
{

}

void Update()
{
float distance = Vector3.Distance(transform.position, Player.transform.position);

if(distance < WalkDist)
{
Vector3 dirToPlayer = transform.position - Player.transform.position;
Vector3 newPos = transform.position - dirToPlayer;
}
}
}

}
}

Please read this: https://discussions.unity.com/t/481379

In this script you don’t apply the newPos anywhere.

Though you can and currently doing this through code, Unity has built in Navigation for enemy AI. Go to the Window tab ->AI->Navigation. Something cool to play around with. It will map out stuff like this for you.