Add change_scene_to_node()#85762
Hidden character warning
Conversation
23b22da to
7838271
Compare
|
Any activity? |
|
Any news on this? Seems like a very trivial yet useful feature that just hasn't been merged yet? Meanwhile for anyone else with this issue, use this workaround: But it's 1. cumbersome to use in multiple places, 2. very beginner unfriendly, and 3. inconsistent with other |
3993b49 to
b441162
Compare
1fa088b to
37f5e1a
Compare
|
Consider the user doing something like (simplified): var node_a := Node.new()
var node_b := Node.new()
get_tree().change_scene_to_node(node_a)
get_tree().change_scene_to_node(node_b)It potentially might be surprising for the user that For comparison Besides that code LGTM, the addition is trivial. |
|
Something like this? |
Yeah, LGTM, sends the message. 👍 |
37f5e1a to
268e4b5
Compare
kleonc
left a comment
There was a problem hiding this comment.
LGTM, the addition makes sense, and looking at the reactions there's a demand for it.
268e4b5 to
a34f7bf
Compare
a34f7bf to
88a5cd2
Compare
|
Thanks! |
|
Wow. I just literally ran into a situation where I want something like this. Glad to know it's been merged. Talk about timing 😅 Thanks!! |
This PR adds a new method:
change_scene_to_node(), which changes the scene to node. The code already existed, this change just extracts part of it into a new method. Thus callingchange_scene_to_file()will callchange_scene_to_packed(), which now callschange_scene_to_node().The new method is useful when you want to do some setup to the new scene before changing.
Also corrected the docs, which claimed that the new scene is instantiated after the old one is removed, which wasn't true.
Closes godotengine/godot-proposals#921
Closes godotengine/godot-proposals#9243
This does not implement the part where the old scene can be left intact, because it's not very useful. My current approach to the problem mentioned in the proposal is adding the menu scene on top of game and pausing the game; changing scenes temporarily is not a good practice.