Question by
Vio_Van_Helsing · Mar 25, 2020 at 08:25 PM ·
c#navmeshagentwander
NavMesh.SetDestination messing up wandering
I have a NavMesh.SetDestination function on my enemy that makes it follow the player when they are in a certain range. Otherwise, the enemy has a co routine to wander around.
When I start the game, the enemy wanders around as per the script. If I get too close, it will begin to chase. But when I get out of range again, instead of continuing with its wandering routine, it just goes in circles, or back and forth, getting nowhere. Does anyone know what's going on?
Comment
Answer by streeetwalker · Mar 25, 2020 at 09:04 PM
@Vio_Van_Helsing, The problem is in your wandering code, obviously! Without seeing the code, the only thing anyone could say is, make sure you are checking to whether or not SetDestination returns true before you start wandering.
Your answer
![](https://koobas.hobune.stream/wayback/20220612225729im_/https://answers.unity.com/themes/thub/images/avi.jpg)