If position walkable

Hello,
I am using the A* for path enemy pathfinding
Now, At the time of map loading All all enemy spawn point are received from the server. What I want to find the given vector3 position is walkable or not, if not will not spawn anything or walkable it will.

How I can achieve it ??

Hi

You can find the closest node to a given position using

var info = AstarPath.active.GetNearest(position, NNConstraint.None);
if (info.node.Walkable) {
    // Closest node was walkable, the closest point on the node to the point was info.position
}

Or you can find the closest walkable point on the navmesh to a given position using

var info = AstarPath.active.GetNearest(position, NNConstraint.Default);
var closestPosition = info.position;

This assumes you are using version 4.x of the package, if you are using 3.x then you have to use info.clampedPosition instead of info.position.

1 Like

Thanks I will try this out

EDIT : Its working