navmesh icon indicating copy to clipboard operation
navmesh copied to clipboard

how to get a random point on navmesh

Open orion3dgames opened this issue 2 years ago • 1 comments
trafficstars

Hi there,

Thanks so much for a great library,

I'm trying to get a random point on the navmesh, is this someting possible? And what would be the best way about it?

I know this is a not issue as such, but I have no idea where to ask this question, and it could be a feature? :)

orion3dgames avatar Dec 07 '22 06:12 orion3dgames

If you're using Phaser, you could use Phaser.Geom.Rectangle#getRandomPoint to get a random position and then use NavMesh#isPointInMesh to see if it's inside the navigable area. Otherwise you could reverse engineer the Phaser implementation as it's rather straight forward.

jorbascrumps avatar Jul 07 '23 18:07 jorbascrumps