Where should I store my Health Value!
Hey guys simple question!
Where should I store my character stats, like health, amount of lives and items collected.
The player can died and respawn, so holding them in the character is a bad idea, I was thinking the player controller is that correct? because if they die controller does not get deleted.
asked Feb 10 '16 at 05:40 PM in Blueprint Scripting
It always depends on your needs. In most cases, the Pawn is suitable.
If you are going to develop for multiplayer, you have to consider whether other people should know of your health.
The PlayerState is automatically created per player and is replicated between players.
I for myself prefer PlayerState. and use the Mode to decide what happens in certain circumstances.
For example I have a Health and Air Value in my PlayerState.
The GameMode checks if my Pawn is underwater. If it is, the Air is reduced. If the Air reaches 0, the Health decreases,too.
answered Feb 11 '17 at 09:00 PM
You are free to store it anywhere you like, you always need to consider the game you are making. In your case, I would personally store it in the Player State. It is replicated, so it can function in multiplayer too, and it consists for the whole game, but keep in mind that loading a new level will reset the values in it.
Might as well look at this answer : https://answers.unrealengine.com/questions/387315/storing-character-stats.html
answered Feb 11 '17 at 01:37 PM
Store them in the character it's easier to manage, just don't destroy that character when it dies. Just remove life or drop the items.
You're the one that has to decide what happens to the character when health reaches 0, it doesn't mean you have to destroy that character, just set its location somewhere.
answered Feb 13 '17 at 05:09 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here