[Solved] Health Transfer in Scenes

Before proceeding, please use the forum search feature at the top of the page to check if your question has already been answered.

How do I…

Im trying to make a level based rpg with a basic health system. I installed the health behavior to the player and created a text object that shows the current health of the player/max health of the player. I want to transfer the health into the next scene

What is the expected result

When the scene changes the health should stay the sme

What is the actual result

Health goes back to default

Related screenshots

Please include a screenshot of the full related events including both conditions and actions.
And screenshots to help showing us the issue.

Project files (optional)

Insert a minimal game showing your issue in a .zip or .rar.

Hi, you need a global variable for that. You can read more about it here: Global variables - GDevelop documentation

what would i link the global variable to

It should be the same value-expression that you display in your text object without ToString.

i have the text object linked to the health behavior itself

Yes, your global variable would look something like this:

In your other scene you can display the value of the global variable like:

could I still use the health behavior to control health and max health in the second scene

Yes, you can set your player object as global and then all the behaviors etc. that are attached to the object transfer to the next scene as well. Generally, all extensions and behaviors that you have installed in your project in one scene are also available in other scenes without the need to install them again. You would just need to attach them to your object again in case you don’t want to set it global.

If you set an object as global you cannot reverse that any more, so before doing it, you should be sure that this is what you want.

instead of making the player global, could I copy and paste into the other scenes

Yes, you can copy the object and paste it into the object-window of the other scene and the attached behavior will be there as well.

I tried it but the health did not transfer

nevermind. I got it to work. Thank you so much

1 Like