Godot Version
4.3
Question
I am trying to add a modular health system to my 2D platformer and there’s a few things I’m unsure on that I was hoping I could get clarity on.
I want to create a health component that I can attach to both the player and enemies in my game. However I need the health to persist on the player between level changes, etc. Additionally when the health changes on player I want these changes to reflect in the HUD.
I was considering creating a resource class for persistent player data. In which case should my player script be responsible for connecting to signals in health component and updating the resource class accordingly?
As for the HUD, should it be the responsibility of the player to update it whenever the health component is changed? Or should the HUD automatically connect via signals contained in health component (meaning the HUD will be dependent on child health component of player) ?
All in all I’m trying to create a modular health system that doesn’t have a lot of dependencies and I’m mostly wondering the responsibility each piece should have in my health system.
If y’all could suggest a solution that would be awesome and greatly appreciated!