The best way to explain this will be to give an example.
You the player starts the game with 10 health. You come across an enemy with 15 health. When you defeat him your health will be 15 health now and the same would be for if you defeated an enemy with a health of 5, your health would become 5 health.
Another quick explanation of what I’m going for. I want to pass the enemies health to the players health when the enemy dies.
so if you the player has 100 health and you kill an enemy with 50 health you now will have 50 health. If the next enemy you come across has 125 Health and you kill him, you will now have his health which was 125.
Again I apologize if you already read it right and what you posted is the way to do it. I just wasn’t sure when you wrote, “Then when YOU die.”
What that seems like is that I would be passing the health to the enemy when I die.
I’m really new but determined to really learn, so any more explanation would be greatly appreciated.
I believe I came up with the answer. It seems to be a very simple way and I’m not sure if this is what you meant Ben, but I appreciate the help and it gave me motivation to figure it out, seeing that others were putting there time into helping.
I did this in the enemy BP so I can cast to the player and it should be easy to put it into other enemy BPs so I can easily change the variables that are cast to the player after the enemy is defeated.
I’m going to post my screenshot of what I came up with, so any feed back would be greatly appreciated. Just so I can get an idea if this is the right way of going about what I meant to accomplish.
On your base class for players add a function called, UsurpLife, give it an integer parameter. When this function is called, make sure the parameter Life is over 0, then add that number to your character’s current, and max health.
When you receive the attack in your On Component Overlap, it passes a reference to the actor, cast this to whatever is your base class for players, then store it in a variable LastAttackingPlayer. Then when when you die, check to see if LastAttackingPlayer is valid, if so, then call a function UsurpLife, and pass your max health.