Hi everybody i’m very new to Godot and loving it so far.
So, I’m trying to blueprint a dungeon builder with that kind of flow
func dungeonBuilder(a given room)
iterate over open doors from that given room
instanciate a random new room from the premade pool & synchonise position/rotation to fit
check if it overlap an other room
if so, try others or close that door and continue
register room data
switch a control bool used inside dungeonBuilder() to handle overlaping management at dungeon generation time
iteratively call dungeonBuilder()
It works great, every new room is correctly merged to the rest of the maze and emit an overlap signal as intended, BUT… i can’t manage to catch thoses signals inside my dungeonBuilder(), in fact, all signals are delivered AFTER the end of _ready() call, preventing me to handle overlaping during dungeon generation.
I even tryed to await some frames to maybe let signals lives theirs lifes
it sometimes kind of work, other times it break my code, making me feel very dumb
Here is the full code : godot-4.2-level-builder/scenes/levels/root_level.gd at main · daSanchezMeister/godot-4.2-level-builder · GitHub
I have no clue how to workaround this case, i may have taken some weird design decision, if you think so please let me know as i really want to improve my skills.
Have a nice day folk!
The physics server updates once per physics frame. If you are creating areas/bodies and checking collisions against them inside a loop it won’t work as the physics server has not updated its state. You’ll need to wait at least a physics frame before being able to query the physics server for collisions/overlaps.
I’ve not tried this but it may be better not waiting for signals to fire and, after
awaiting for the signal
Area2D.get_overlapping_areas() or query the physics server directly by using the
PhysicsDirectSpaceState2D if you only have a
You right, it worked !
Awaiting physics_frame instead of process_frame was the way, so i could use the inbuilt Area2D method instead of trying to catch a custom signal inside my dungeon build logic :
then await again before every dungeonBuilder call
for i in range(max_dungeon_size):
Thanks a lot kind sir <3
Funny fact is as every iteration has an awaiting frame i literaly see the dungeon building in front of me at runtime and got so amazed by the maze it outcomes