Mugen87 / yuka

JavaScript library for developing Game AI.
https://mugen87.github.io/yuka/
MIT License
1.1k stars 90 forks source link

WanderBehavior within Navmesh #41

Closed YuryKonvpalto closed 3 years ago

YuryKonvpalto commented 3 years ago

Hi Guys!,

Is it possible to apply a e.g. WanderBehavior within a NavMesh? - I mean a vehicle would wander aimlessly within bounds of a NavMesh? Or one can use only pathes in Navmesh?

Mugen87 commented 3 years ago

You can combine both but the bounds check is not something that happens automatically. Meaning you have to use NavMesh.clampMovement() so the game entity does not leave the nav mesh.

Notice that this approach potentially produces odd results since the wander behavior might steer the entity into a direction which leads off the nav mesh. Due to the clamping, it could look like the entity is running against a wall. Normally you would expect the behavior changes the direction if a boundary is going to be hit. So it might be better to create a custom steering behavior for this use case.

YuryKonvpalto commented 3 years ago

Thanks a lot!