Godot is not removing objects from the queue fast enough to rebake layer in the same function but if i call bake later it works. Is there a way to call it on something like @onready with in the function?
Here is the function:
You could try to Callable.call_deferred() the bake_navigation_polygon() function like: $"..".bake_navigation_polygon.call_deferred() or await for a frame before calling that function like:
The bake function will parse all the nodes with whatever properties they have the moment you call it. There is no delay there, it runs synchronous.
A queue_free() will not remove the node immediately but only on the next process idle. So if you want a node removed immediately from the SceneTree you need to use in addition e.g. remove_child() or something on that node.
A delay only exists for the actual bake when you do it on a thread (default) and for the part where the NavigationServer needs to process all the updates until the change can actually show up for new path queries.