I need help
I want the enemy to follow the player at a specific distance 2d game top down
Hi
If you use the AIPath/RichAI movement scripts you can set the ‘end reached distance’ to your distance and then set the ‘whenCloseToDestination’ mode to ‘Stop’. This will make the AI stop when it comes within a certain distance of the player.
1 Like
Thanks for the reply
But I want the opposite
I want the enemy to attack the player when reaching a certain distance
Is not there to help
I am a novice in this field
Hi
If you have some attack code you can check when you should start to use it using the ai.remainingDistance property.
1 Like
You can use something like:
if(Vector3.Distance(transform.position,
new Vector3(player.position.x, transform.position.y,
player.position.z)) <=_distanceToAttack)
{
// Attack
}
1 Like