I am currently setting up the mechanics of my game and I made a cube that I named “lava” to test the health mechanic. It was working just fine but then it all of a sudden stopped. I made a print string blueprint to test if the damage was actually dealing and there was just something wrong with the health bar but when I printed the health variable it kept showing up 9 (the default value was 10) no matter how many times I stepped on the “lava.” Do you know what happened?
Oh, thanks. I found that on event tick it would set health to the max health variable which was supposed to make it so you could expand your health. It kept setting health to 10 every tick.
It was supposed to be on event begin play but once I added a main menu I changed the create widget to event tick but I accidentally also moved over the set health to max health. Thank you!
Perhaps it might be helpful if you first decouple your testing and create a simple function (maybe just directly inside your player BP) which degrades your health by a given amount.
And then see if that works. If that works, recheck the code that triggers health-degradation in your context (l assume your lava object degrades the health variable)
Also one thing… nothing changes suddenly without you changing something. Perhaps you saved an asset in-between your test-runs and made a slight change there.
So yeah, basically take your problem out of your world and object context, seperate your tests and then put the components you now know work in isolation back together and check if your “glue” between those components work as intended. This way you can quickly remove any outside noise that could be created by any kinds of things.
Let us know what the problem was and if this approached helped you. Cheers