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;
}
}
}
}
}