Quantcast
Channel: Answers for "Getting enemy to move towards player untill they collide problem..."
Viewing latest article 1
Browse Latest Browse All 6

Answer by BenKurdziel

$
0
0
You don't have a catch for collision in that code. So it will do that no matter what, even if you collide. Put a Box Collider around the enemy and set it to IsTrigger. Check OnTriggerEnter (other : Collider) to see if that other object is the player. If it is, set your speed to 0 (assuming you want them to stop moving). Another option is to test their distance from each other and if their distance is less than a number you choose, you stop the NPC.

Viewing latest article 1
Browse Latest Browse All 6

Trending Articles