#Applying variables to Instantiated Scene
8 messages · Page 1 of 1 (latest)
Do you mean when you change scenes with SceneTree.change_scene_to_file/change_scene_to_packed? If that's the case, you can save the data when the _exit_tree() func is called and re-apply it again when the player is re-created in the new scene. To save the data you can create an autoload (aka singleton) to hold the data. See https://docs.godotengine.org/en/stable/tutorials/scripting/singletons_autoload.html
Introduction: Godot's scene system, while powerful and flexible, has a drawback: there is no method for storing information (e.g. a player's score or inventory) that is needed by more than one scen...
Not at runtime, but in the editor:
If i want to change the moveSpeed variable of a player, but do it from the Main Scene view and not the Player Scene view, is it possible to push those changes to the Player Scene?
as in, edit properties while in the Main Scene but have them save to the Player Scene
because currently the Player in the Main scene has its own unique properties
In Unity this is an "Apply Changes to Prefab" button
Oh. No. There's no way to do that out of the box. Possibly neat idea for a plugin though.
What I do is make the changes in - say - the Player scene, rather than the Main scene. And by that I mean, changing the value in the Property Inspector for the player scene. The code for the exported property will still have the original value I defaulted it to. But when the player scene is instantiated from any other scene, that value I set in the Property Inspector will be used.
Does that make sense?
yes. so basically I just gotta adapt.