godotengine / godotengine/godot-docs

Confusion around node lifecycle and best practices documentation

Open
#9,290 0 comments 0 reactions 0 assignees View on GitHub
area:manual enhancement
Dominant language
reStructuredText
Stars
5.7k
Forks
3.8k
Avg merge
1d 20h
Merged PRs (30d)
25

Description

**Your Godot version:** 4.2.1

**Issue description:**
Coming from a background of react web development, I would love a page on the lifecycle of nodes, especially with regards to best practices around `_ready()` and when nodes become visible to the eye (rendering) in the viewport.

***Some questions I have:***
- From print statements and breakpoints, it seems like nodes become visible as they enter the tree (`_enter_tree()`). But if I pause with a breakpoint in Parent A's `_ready()` function, I don't see Child B rendered in the viewport, despite it having `visible == true`. Does this mean the rendering of children waits for the parent to be ready?
- Are there any pros/cons with changing reusable Child B's variables in Parent A's `_ready()`? Say we want to change a variable called "color" of Child B from red to green because this instance should be green. Is there a frame where Child B is "color" red if we change "color" in Prante A's `_ready()`? Would it be better to listen to the `NOTIFICATION_PARENTED` notification (which should happen as the node enters the tree if the nodes are setup by the local hierarchy and not a script) and change the variable instead (maybe bypassing Child B being ready with the incorrect value)?

***Potential pages where these changes could go:***
- https://docs.godotengine.org/en/stable/tutorials/scripting/scene_tree.html#becoming-active-by-entering-the-scene-tree
- https://docs.godotengine.org/en/stable/tutorials/scripting/overridable_functions.html
- https://docs.godotengine.org/en/stable/tutorials/best_practices/godot_notifications.html#doc-godot-notifications

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.