Projectile only causing damage to the actor who fired it

Hello, Thank you in advance for any help.

My game involves a character firing a projectile to another character. My issue is I was able to create a damage system that works well but only when the character that is getting hit by the projectile is possessed. For example, ill fire a projectile straight up in the air so it will land on the same actor that fired it and it will damage him. If I fire the projectile at another character it won’t do anything. BUT if I fire the projectile at the character then quickly possess him it will cause damage. Any idea as to why?

My damage system is a progress bar i have in my user interface

My damage system for each character is in there own blueprints telling the character when its hit by the projectile do damage. My guess is it has something to do with the possession? Like should my damage system be in the level blueprint not the individual character one? if so how would i reference each character?

Thank you

Just to be clear, when you say your behavior for applying damage to each character is in the character’s blueprint, which specific blueprint class is the damage logic under?

“Character” can mean the built-in ACharacter class, which is a type of Pawn (deriving from APawn), in which case that narrows down the issue. Or maybe it means “character” in a more general sense, which leaves things open to interpretation.

Basically, I just want to make sure that your damage logic is not being done under your Player Controller blueprint (if you have one — same goes for any AI Controller you might have). If it is, that would explain the problem, since controllers possess pawns, and if the pawn is not possessed at the time it is struck by a projectile, then there is no controller ‘present’ to process the damage.

I actually doubt that the damage logic is on the wrong place, but I thought it best to make sure before digging in deeper.

I mean the character class


hopefully that helped

Can you share more about how you’ve got your blueprints set up? I just set up a basic test project using the FirstPersonExample template, and got the projectile to fire the Hit event every time — even when the other character was not possessed.

So I figure, there must be something else going on that I’m not expecting.

@the_batch has a point. You probably change the HUD variables, and HUD is a part of a Controller. What you have to do is change the variables in the BP of the pawn that’s hit, and change the HUD values upon possessing that pawn.

from what i can see here it looks like your doing things a bit backwards yous checking for hits with the character and casting to the projectile bit in my opinion it should be the other way around.

basically in your rocket you should have a on hit event that then checks to see if the hit object is a character and if it is then apply damage and destroy self.

then in the character you have a event any damage which takes the damage and subtracts it from a health variable. in your hud you have a binding for the progress bar which normalizes the health variable and thats how you handle the visual representation.

if you do it like this then your projectile will be able to damage any character, and as long as that character has a way to handle damage as mentioned then it will receive the damage and lose health.

of course you could eliminate the check for character is you wanted to damage other targets as well. and you would possibly need a method so the projectile doesnt harm the one that fired it when its fired but thats a pretty simple check. but a little beyond this post.

Hopefully this helps and is what info you are needing i apologize im not to smart with this quite yet, but the image below shows the user interface for one of my characters i have (my tank) i circled my health bar as well as what the percentage binds to

The reason for this behavior is probably because your event is in the HUD class, which is only created for a player controller. This is why it only works when you posses. Just move it into the character blueprint and it should work just fine.