How to get a random point from NavigationServer3d with respect to NavigationLayers

Godot Version

4.4

Question

How to get a random point from NavigationServer3d with respect to NavigationLayers

Hello i am using C# an Godot 4.4.

In my scene i have
→ Main
→→World
→→NavigationRegion3D
→→→GridMap

My GridMap use a MeshLib with multiple tiles. There are 2 tiles called floor_a and floor_b. In the GridMap i have set the NavigationLayers for floor_a and floor_b to be 2 and removed them from 1.

I tried:
var mapRid = GetWorld3D().NavigationMap;
spawnPosNav = NavigationServer3D.MapGetRandomPoint(mapRid, 2, false);

This just gives (0, 0, 0)

  1. GetWorld3D().NavigationMapDoes this get NavMesh that is in the GridMap?
  2. How can i use NavigationServer3D.map_get_random_point to get a point that is on guaranteed to be in layer 2?

When are you trying to get that point? The NavigationServer3D does not update until the next physics frame. From the documentation:

Note: Most NavigationServer3D changes take effect after the next physics frame and not immediately. This includes all changes made to maps, regions or agents by navigation-related nodes in the scene tree or made through scripts.

I didnt know that, but i dont think thats the issue i am running into

This is called repeatedly every ~2s. in the _Ready of one of my nodes. The nav mesh does not change once the GridMap is setup.