Detect if On Grid?

Is there any boolean that tells you if you are on a walkable part of the grid? I’d like to know when a character gets hit out into no man’s land if possible.

Thanks for any help :).

Well, in my games I just check before making a path if its Possible: This is useful for if errors pop up. Or if your player makes a strange path (Like somehow clicking out side of the map in a RTS)

`public bool CheckIfPathIsPossible(Vector3 PathStart,Vector3 PathEnd){

	Pathfinding.Node node1 = AstarPath.active.GetNearest(PathStart, NNConstraint.Default).node;
	Pathfinding.Node node2 = AstarPath.active.GetNearest(PathEnd, NNConstraint.Default).node;
	
	if (!Pathfinding.PathUtilities.IsPathPossible (node1,node2)) {	
		
		return(false);
	}
	else{
		
		return(true);
	}
}`

Also. The scripts will try to find the closest walkable nodes when trying to target unwalkable nodes (or nodes outside the graph). The maximum distance that will be searched is defined in A* Inspector -> Settings -> Max Nearest Node Distance.

Sorry I guess I wasn’t clear or I’m not understanding.

Take this image for example.

Here the black square and its insides represent walkable area.

The blue circles represent some example positions where the IsOnWalkable boolean is true, and the red circles are some example positions where that boolean is false.

What I need to know is if the character is no longer in the walkable area. I don’t need to know how to get back or if they even can get back.

Thanks very much for the help.

Basically what you want to do is to find the closest node, check if that was within a specified distance or if it was unwalkable.

Node node = AstarPath.GetNearest(transform.position, NNConstraint.None).node; if (node == null || !node.walkable || ((Vector3)node.position - transform.position).sqrMagnitude > limit*limit) { Debug.Log ("Red"); }