Hello, I am working on establishing some basic health variables for my player.
I have a save system that stores health and other player stats inside of my Player Controller, but I seem to be running into some issues with ApplyDamage and creating respawn checkpoints.
From my understanding, using a player controller allows the user to save variables, states, etc.(replication or standalone) regardless of whether the player was alive, or possessing a new blueprint. This is important as I need to be able to possess pawns without losing track of anything important to the player themselves. So, I created a save game blueprint to store my important variables inside of a structure. Then, inside of my new player controller, I decided to ask whether or not a save exists on begin play. This allowed me to initialize player controller variables (such as health or score) based on default save variables. However, I wanted to add in a player respawn to further test my save game system, and to see if I could reset the player health after dying (something like death>delay>spawn@transform>loadsave). My controller is currently using the EventAnyDamage to subtract health, and if my health int reaches zero, it’s supposed to call a destroy actor that targets my third person character reference.
I could not figure out how to use the pain volume to apply damage to my player controller, unless I added a node in the level blueprint to apply damage on overlap. Only applies damage once, which kinda seems to defeat the purpose of using a pain volume. I could get a trigger volume to act the same way, and if I wanted to, call the event again over an amount of time.
I have found that even if the health int reads zero, the check isn’t considered valid until a subsequent damage trigger is called. Likely the way I have my branch set up, that it’s seeing <=0 as false until it gets checked again.
Finally, I can’t seem to figure out how to properly call a respawn for my destroyed actor for the life of me. Ideally, I would like to call a vector in another actor blueprint that I have a 3D widget for to manipulate the exact spawn location. I am currently just trying to spawn the character back at their initial location in the world. Every attempt to respawn the destroyed actor either doesn’t actually spawn the character, or respawns the actor at the exact location where they were destroyed, even though my transforms are spitting out the right coordinates (The initial location of the actor placed in the level).
My console no longer gives me any error messages either, and breakpoints seem to flow all the way through my code.
I can’t say for sure that my controller is causing these issues, in the event that it’s a mistake in my coding, I’d really just like to know if these variables and checks should be handled in the character, not the controller.