Solved] Health Transferring to New Scenes Help

Hey there!

I’ve had this problem going on for a while, but I’ve been unsure the best way to fix it.

I’ve installed the ‘Health’ extension, and I have a global variable also called Health.

I have it coded like this, in my ‘Always Running’ external events folder:

Since it’s ‘Always Running’ nothing I click or press affects these events, they’re just always there and functioning.

The animation of ‘Life’ works perfectly, and when Health is zero, the player does officially die, so that works great, but with each new scene, Health returns back up to 3. Since I’m using a global variable, I’ve been confused why it does this, so it must be something I’m not understanding.

I’ve tried a couple different options, but nothing feels right, and I suspect because it’s an extension that there might be an easier, more efficient way to go about coding in the health to follow the player into new scenes.

Eventually I’ll also include the option to up a players health, too, but right now I would just like to fix the health resetting in every scene.

Thanks so much!

The health extension is added as a behaviour on the player object. When you load a new scene, the player object is instantiated, as is the health behaviour on the new player object. The health settings will be the default ones you have defined in the health behaviour settings.

If you want to use the global variable to keep track of the player health over scenes, then in the "Always Running’ scene add a At the beginning of the scene condition, and set the player’s health to the value of the global variable. Remember to also save the Player’s health into the global variable before the scene is exited.

3 Likes

Hey, that was so easy, thank you! Much easier than I expected! It’s finally working properly, I appreciate the help!