oh i think this relates to my question in your first video whereas its a part of the scene but not a child of it so we need to add it as a child. Thank you thats very clear
Ty so much, new dev on godot coming from unity this really help. Is there a way to get the same color of your editor? On unity i had a theme with similar color so i really like it
You are very welcome. Yes, you can go to editor, then editor settings, then theme, then use 11124b for the base color, and use ff0090 for the accent color.
If I understand correctly, you want to preserve/save the changes that happened in a scene (eg. changes in positions of each node), and when you switch back to this scene you want to continue from where you left off. In this case, it is best to detach/remove the root node of your scene instance, and attach it back when you want, using add_child.
Yes, usually we will remove/detach the scene of the current level, and then replace it with another one. But most of the time you want to use queue_free() after removing the scene to release the resources occupied by the removed level. A better way to do it is to use change_scene_to_file or change_scene_to_packed (they will remove the current scene, free it, and then add the new one for you). I might do a video about them : )
@@raysandrarexxia941 According to the documentation, they delete the current scene. From the documentation: "We can delete the existing scene. SceneTree.change_scene_to_file() and SceneTree.change_scene_to_packed() will delete the current scene immediately." Source: docs.godotengine.org/en/stable/tutorials/scripting/change_scenes_manually.html Maybe try using .free() as the documentation says.
i have a problem with .show() .hide() when node is a scene my code doesn't work properly But when its a @editible children(in scene) it works... But not when its not editible scene (22/02/24) p.s. thanks for remove_child() p.s.2 Nope even remove_child() doesnt help
If you are invoking .show() .hide() on the packedScene (the resource returned by load/preload), then this won't work. You need to invoke .show() .hide() on the node that is returned when you instantiate the scene.
deepai ""In Godot, when you instantiate a scene, a node called the "root node" is returned. This node represents the top-level parent of all nodes within the instantiated scene. It serves as the starting point for accessing and manipulating other nodes and components within the scene hierarchy. By interacting with the root node, you can dynamically add, remove, and modify nodes and their properties within the scene." oookey But always used root source node... yes or not
@@ser-pzdts You are welcome! Let's look at it this way: var packedSceneRef = load("res://path/to/scene.tscn") # this is a packed scene var sceneRootNode = packedSceneRef.instantiate() # this is the root node of the scene (this root node and its children have an identical structure to the scene you defined/instantiated) add_child(sceneRootNode) # this will attach the (root) node as a child to the node that has the script attached. sceneRootNode.hide() # this will hide the (scene) root node and its children. You can also access children nodes of the sceneRootNode and hide them independently. I think these 2 videos may be helpful: => czcams.com/video/um2dqyH-_YE/video.html => czcams.com/video/h7lg-gpb5H4/video.html
@@JumboGamedevIm not using code to instantiate the scene pack Im using just mouse-interface panel. The absolute path of the scene pack im getting by click and drag the node (feature)...
@@DoubledEthan add_child() adds a node as a child of another node, while add_sibling() adds a node at the same level as another node (ie. it becomes a child of the same parent).
Removing a child node detaches it from its parent but keeps it in memory (ie. the node is there, but it is just not attached to the tree. You can attach the node back to the tree if you want). queue_free() marks the node for deletion, removing it from memory after the current frame.
The SceneTree animation with sound felt like the Mini Metro aesthetics! I Love it!
Thank you!
These short videos are so good. You're gonna have a lot of subscribers very soon with this quality and intuitive break downs.
Thank you very much!
This was so helpful!
Thank you!
oh i think this relates to my question in your first video whereas its a part of the scene but not a child of it so we need to add it as a child. Thank you thats very clear
You are very welcome!
This is exactly what I need, so clearly. Thank you!
You are very welcome!
underrated channel
Thank you!
Well explained :)
Thank you!
Impressive, thank you so much!
Thank you so much😁
Ty so much, new dev on godot coming from unity this really help. Is there a way to get the same color of your editor? On unity i had a theme with similar color so i really like it
You are very welcome. Yes, you can go to editor, then editor settings, then theme, then use 11124b for the base color, and use ff0090 for the accent color.
Awesome video, thanks for sharing your godot knowledge. I'm curious, do you by any chance use Motion Canvas to make these videos?
Thank you very much! No, I don't use Motion Canvas.
Soo i making a game and i want to change scenes without closing it and i dont know how
If I understand correctly, you want to preserve/save the changes that happened in a scene (eg. changes in positions of each node), and when you switch back to this scene you want to continue from where you left off. In this case, it is best to detach/remove the root node of your scene instance, and attach it back when you want, using add_child.
Sensei,
Is this how map/level changes in rpg games?
Yes, usually we will remove/detach the scene of the current level, and then replace it with another one. But most of the time
you want to use queue_free() after removing the scene to release the resources occupied by the removed level.
A better way to do it is to use change_scene_to_file
or change_scene_to_packed (they will remove the
current scene, free it, and then add the new one for you). I might do a video about them : )
@@JumboGamedev Yes please!
@@JumboGamedev the change scene methods don't actually delete the old scene. They are still in memory and it's causing problems with my game.
@@raysandrarexxia941 According to the documentation, they delete the current scene.
From the documentation: "We can delete the existing scene. SceneTree.change_scene_to_file() and SceneTree.change_scene_to_packed() will delete the current scene immediately."
Source: docs.godotengine.org/en/stable/tutorials/scripting/change_scenes_manually.html
Maybe try using .free() as the documentation says.
Can you do a video on loading screens?
Yes, for sure. I will try my best to do it soon : )
i have a problem with .show() .hide() when node is a scene my code doesn't work properly But when its a @editible children(in scene) it works... But not when its not editible scene (22/02/24) p.s. thanks for remove_child() p.s.2 Nope even remove_child() doesnt help
If you are invoking .show() .hide() on the packedScene (the resource returned by load/preload), then this won't work. You need to invoke .show() .hide() on the node that is returned when you instantiate the scene.
@@JumboGamedev""on the node that is returned when you instantiate the scene." sounds difficult for me Anyway thanks for response
deepai ""In Godot, when you instantiate a scene, a node called the "root node" is returned. This node represents the top-level parent of all nodes within the instantiated scene. It serves as the starting point for accessing and manipulating other nodes and components within the scene hierarchy. By interacting with the root node, you can dynamically add, remove, and modify nodes and their properties within the scene." oookey But always used root source node... yes or not
@@ser-pzdts
You are welcome!
Let's look at it this way:
var packedSceneRef = load("res://path/to/scene.tscn") # this is a packed scene
var sceneRootNode = packedSceneRef.instantiate() # this is the root node of the scene (this root node and its children have an identical structure to the scene you defined/instantiated)
add_child(sceneRootNode) # this will attach the (root) node as a child to the node that has the script attached.
sceneRootNode.hide() # this will hide the (scene) root node and its children.
You can also access children nodes of the sceneRootNode and hide them independently.
I think these 2 videos may be helpful:
=> czcams.com/video/um2dqyH-_YE/video.html
=> czcams.com/video/h7lg-gpb5H4/video.html
@@JumboGamedevIm not using code to instantiate the scene pack Im using just mouse-interface panel. The absolute path of the scene pack im getting by click and drag the node (feature)...
How to reattach in code?
You can use add_child() or add_sibling() to reattach a node back to the scene tree.
@@JumboGamedev what's the difference between add child and add sibling
@@DoubledEthan add_child() adds a node as a child of another node, while add_sibling() adds a node at the same level as another node (ie. it becomes a child of the same parent).
I'm guessing removing a child is different from queue.free?
Removing a child node detaches it from its parent but keeps it in memory (ie. the node is there, but it is just not attached to the tree. You can attach the node back to the tree if you want). queue_free() marks the node for deletion, removing it from memory after the current frame.