clarification attempt#11984
Closed
val461 wants to merge 1 commit into
Closed
Conversation
Member
|
Thank you for your contribution but we do not accept LLM contributions like this, these changes make no sense (except for the grammar fix) and are just unnecessary noise Thank you nonetheless |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note on my changes
Line 74 leads the reader to expect collision detection to be relevant at line 77.
Line 125 "adding the scene to the root node" felt confusing since the scene is supposedly already in the root node.
Unrelated note: a beginner's perspective
Explanations of LLM related to the page
1. What is the "Current Scene" (
current_scene)?In Godot, the SceneTree has a specific property called
current_scene. It is not "the first child of root" picked arbitrarily — it is an internal variable that points to a precise node.root, and stores its reference in thecurrent_scenevariable.change_scene_to_file("Level2.tscn"), Godot does exactly the following:get_tree().current_scene.free()on that node (destroying it along with all its children).root.current_scenevariable so it points to this new node.2. How does
rootmanage its children?rootis a node like any other — it can have 10 or 20 children at the same time. But from Godot's perspective, not all of them have the same status:current_scene. It is the only one Godot will automatically remove during a scene change.rootviaadd_child(), or Autoloads (Singletons). Godot will never touch these during achange_scene_to_filecall.Effects of assigning the
current_scenevariableRegarding the assignment of
current_scene(get_tree().current_scene = new_node), here are the concrete effects:1. The target of the next cleanup
The most important effect is telling Godot which node should be discarded on the next call to
change_scene_to_file()orchange_scene_to_packed().free()on it.2. The anchor point for reloading
When you call
get_tree().reload_current_scene(), Godot uses the file path of the node stored incurrent_sceneto reload the level. Ifcurrent_scenepoints to the wrong node, you will reload the wrong part of your game.3. No effect on the hierarchy (Gotcha!)
This is the most counter-intuitive point: assigning
current_scenedoes not move the node within the scene tree.get_tree().current_scene = my_nodebut forget to callget_tree().root.add_child(my_node), your node is still an orphan.rootdoes not automatically assign it tocurrent_scene.4. The order of operations (The clean manual approach)
If you change scenes manually, you must follow this exact order to keep everything consistent: