crystal-bit / godot-game-template

Generic template for Godot games
MIT License
598 stars 47 forks source link

game.gd: "_force_main_scene_load" triggers tree_entered, tree_exited,... when playing a specific scene #54

Closed davcri closed 2 years ago

davcri commented 2 years ago

This behaviour could be annoying for many people that rely on default Node events.

poseiso commented 2 years ago

it this why calling Node.PAUSE_MODE_PROCESS on the _ready function does nothing? If i moved it to start() it functions correctly however the timing is a bit off.

davcri commented 2 years ago

Hi @poseisharp, your issue is not linked to this one. I opened a separate one and in the next version I'll add a fix for your problem! Thanks for reporting your experience!

davcri commented 2 years ago

Hi @poseisharp the issue should be fixed now on main! Let me know what do you think about it!

poseiso commented 2 years ago

Thank you, looks good now.

Also I've found a somewhat weird behavior but this might be intended. When I ran a single scene it triggers _force_main_scene_load() In the scene I have a Tween.start() in the _ready() function the tween did start but it looks like it didn't work, then I realized that the scene is removed from tree and added back again by _force_main_scene_load() since it's only removed from the tree the _ready() function is not called for the second time. And tween resets on tree exit so it looks like the tween does nothing.

But yeah things are working well if the main scene is already running with the container.

davcri commented 2 years ago

Thanks a lot for checking and reporting!

As you already guessed, it's a side effect of _force_main_scene_load(). I plan to rewrite this part in a simpler way (I want to avoid removing and re-adding all the nodes on "play scene").

davcri commented 2 years ago

The commit 17b19e6a19cf3e146968100c64b3297a7d84c034 includes a big refactoring of the game-template into an addon. Now the project should be easier to use: