Hello,
I am trying to find a random point in the navmesh to teleport an Actor to this location. The idea is to find a random point that is reachable but it has to be at least at a certain distance from the origin (the player in that case).
The issue I have is that… When the origin is near the edge of the navmesh, or if the navmesh is too small, the actor is out of the navigable area and stops.
So… I would like to know if there is a way to find a random point inside of the navmesh, at a certain distance from the origin and make sure it stays inside of the area.
Or a way to efficiently get the furthest point from the origin if the area is too small.
I already expanded it on the whole map but if the player ends up near the edges of the map, then things become more difficult…
To give you an idea: I want an actor to get a point in the navmesh that is at least 3000 units away from the player in a random direction. But if I’m near the edges of the map, I want to make sure I don’t get 3000 units or more outside of the map but in a direction still on the navmesh.
But I’m not sure how to get a random location that is at least 3000 units away in a random direction while making sure to stay inside of the navmesh.
I tried to get random points until one is valid but is it efficient?
Thank you very much, this solution is working great!
Is it efficient to use a loop though?
Also… If for some reason I end up with a navmesh that is smaller than the minimum distance from the player, I’d like to force the actor to get a point at the closest edge of the navmesh and not outside to have a solution against infinite loops, if that’s possible
Their is a node called get random reachable point on nav that should do it but you need to then use a vector distance node from origin to the found location and check that with a greater than or less than and if its not usable loop back and do it again.
Hope this helps
Use a do n node with the output int on a greater than that way you can let it try n times and on the last one just use it. The loop is fine as it can only run once in a tick as you put a 0 second delay in.