Check if object without NavMeshAgent component is under navmesh

185003-screenshot-2021-08-18-150624.pngSo, the player object is not using the navmesh, it is controlled by a virtual joystick altough I have a map baked for the mobs. I am trying to teleport the player randomly inside the navmesh, so he does not go outside the map. How can I check if his position is under navmesh if it does not have a NavMeshAgent component? Or is there a better way to prevent him from teleporting outside the “box”?

Do the objects (walls etc.) of this labyrinth have Colliders ? then you could teleport your player to a location inside of it after checking with Physics.CheckSphere if theres enough space for your character model at that point.
Besides that there is NavMesh.FindClosestEdge. “Locate the closest NavMesh edge from a point on the NavMesh.”

if (NavMesh.FindClosestEdge(transform.position, out hit, NavMesh.AllAreas)) now either this returns true/false depending on if you are on the navmesh or not (i am not sure myself how this woudl behave) or if its able to find an edge without being on the mesh, you could teleport your character to that edge and let him spawn closest to where he would have spawned if there was a mesh.