I was given a suggestion for the health system in my game to link two global variables to my players health and max health. This transferred the values over to the other levels when you go through a door “scenes”. I soon realized that in the other scenes the player was unable to take damage or be healed. I was wondering if there was a simple way to make a universal health system?
Yep, just install the health extension. (if you don’t know how to install extensions it super easy, just open the project manager and click the search for new extensions button).
i already have it installed. The global variables are linked to it
Are you saying that you don’t want to have health events in each scene, or is your problem that you do and you just want to have the health and damage connected to global variables?
the problem is that no matter what I do, the player can not take damage or heal in any other scenes except the first
You need to give some more information, send a screenshot of the health events for the first scene and a screenshot of events from the second scene that doesn’t work.
Where are the events that apply the damage/healing in the other scenes?
And are you setting the health extension values to the values in the global variables at the start of the scenes?
I see these are the same events, are these screenshots of the first and second scenes respectively, or are you using external layouts? I also don’t see anything related to damaging the player which is the problem you’re having right? In terms of updating the global variables everything seems fine, what I suspect could be the problem is that even though you update the global variables with the values from the health extension, it doesn’t look like you’re updating the health extension’s variables with your global variables when the scene changes (maybe you are I can’t see from these screenshots). Please share a screenshot of the events related to damaging the player and any events related to updating the health extensions variables.
the top picture is the first scene and the bottom is the other. The health and maxhealth is defaulted to 4 when you start the game. The events apply damage, heal object and all the others don’t work in the second scene
I don’t see any events related to damage in these screenshots?
it is the same damage system for both btw
So in all scenes there’s a
move player away from kikdak before checking for collision?
If so, I’m surprised it even works on the first scene, because logically if the two objects are separated then they aren’t colliding any longer.
wait. Do you think just using global variables instead of the health behavior would work
It’s not like using global variables and the health extension wouldn’t work with the proper implementation, but I think it would be easier to just use global variables because that way you don’t have to worry about updating global variables with health extension variables and vice versa. More so because your health system is pretty simple, you really don’t need to use the health extension anyway. I find the extension useful when you’re trying to implement more complex functions like shields, cooldowns, armor, dodge, etc. But for applying damage and healing players, that can easily be done with the base GDevelop conditions/tools.