Damage Problem

I have created a function that handles the damage when the player jumps on an enemy and is in falling mode. It works fine for one enemy, but when I have more than one enemy, they all get affected by the damage function, even though I only want to damage the enemy below the player. The damage function affects three variables: isDead, health, and isDetected. However, only the health variable seems to change for all enemies, while the other two variables remain unchanged. I don’t understand why this is happening.

The damage function is triggered by a hit event inside the enemy blueprint and casts to the player blueprint.

In the end how can I fix this problem so that only the enemy below the player gets damaged by the function?

thx

Hey @88omer188! Welcome to the forums!

Would you be so kind as to bring us some snippets of your code? It’s going to be really difficult to tell you what’s going wrong without that… Chances are it’s something to do with the cast, though!

1 Like

Thanks for your reply, I have attached Image

Do you mind if I ask a few questions?

If you put the enemies far apart, do they still get affected by the damage?
Have you tested with printstrings to see if the Dead variable is going off?

You can add printstrings throughout to see where the code stops! You should give that a try.

If you need it to make sure the player is DIRECTLY above the enemy, you need to use a line trace from the enemy going up, and use a branch: if the first hit = your character, then continue.

1 Like