Support Forum

Need some help with random Pos

Hi I am using the recast navmesh Grid
is there a Mathode like Unitys SamplePosition ?
Something like this?
randomPoint = center + Random.insideUnitSphere * range;
NavMeshHit hit;
if (NavMesh.SamplePosition(randomPoint, out hit, 1.0f, NavMesh.AllAreas))
result = hit.position;

thanks for help

Hi

You can use AstarPath.active.GetNearest(mypoint).position.
See https://arongranberg.com/astar/docs/usingnodes.html