Could be that not a single pulse is hitting the logic, so it is subtracting more then it should. Try testing with a DoOnce node and see if it changes.
okay i can try and were do i put the do once node
Hey there @LoganPaddled! I think there are a couple issues with the script here so the answer to your original question is that you are setting your “Max Health” to 0 then checking if it’s 0 to decide if it’s to be destroyed. So it will always be destroyed since you’re setting the value to 0 when you take damage.
That said, I’ll go over everything wrong (assuming you actually wanted to use CurrentHealth) with the script for learning purposes.
You’re using the MaxHealth
as a CurrentHealth
in the TakeDamage
function. You should be using CurrentHealth
for almost everything, unless you’re attempting to make a creature reduce the actual maximum health of the player instead of the actual current health.
You were incorrectly subtracting the MaximumHealth
from the Damage value, and then also not hooking it up to your value.
Lastly you checked the MaxHealth
again (that you had set to 0) to see if it was 0 before destroying the actor. Which would always be 0 in this case.
Here’s a corrected way to handle this:
Don’t forget to set your default value for MaxHealth
in the variable defaults itself.
@SupportiveEntity i tried what you suggested they are still dying in one hit tho anything else i can try
oops i was missing a connection in my last photo it works now thank you so much
No problem! One way to avoid logic errors like this early on when you’re learning is to step through each node like you would a line of code. This helps catch mistakes like using the MaxHealth
variable, the subtracting in reverse, and the disconnected nodes all at once. Let me know if you need any more help!
okay sounds good and have a good rest of your day