Quantcast
Channel: Answers for "Getting enemy to move towards player untill they collide problem..."
Viewing all articles
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 all articles
Browse latest Browse all 6

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>