I am new to gdevelop and game dev. I am creating a standard top down RPG game. Every new part of the map is a new scene, in each scene I have dropped a copy of my player object. But I’ve found that everytime I go to a new scene it resets the health of the player to the default values.
I suspect it may have something to do with the player being a new instance or something on each scene.
What is the best way to have my player object available in each scene and shared health values.
All I can think of is to store them all in a variable before the scene changes and load them back in when the new scene starts but surely that’s not the best way
You’re correct. Global variables and storage are about the only things that are available in every scene. There should be a way to make objects and their behaviors global or at least the extension and variables.
In the meantime, you would need to store the value in a global variable or storage and then copy it back unless you create your own method for health that uses global variables.
The term global object only refers to the objects being in the editor regardless of the scene. Once added to a scene I don’t believe there’s a single difference.
When you have change scene action
In same event above that action add change SOME global variable set to and here player health
I do not remember what was correct expression for health behavior
Something like object.Health::blablabla
You will find it with autocomplete
And now in every following scene you need to have event
At beginning of scene
Change player health set to that SOME global variable
And that is how you carry over health of your player over multiple scenes
And to make your life easier how about not using health behavior
And just use global variable for your player HP
I always use global vars for all my player stats never had it failed
And never i needed any action or condition that health behavior provides