x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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

Product Version: UE 4.21
Tags:
more ▼

asked Jan 03 '19 at 05:17 PM in Blueprint Scripting

avatar image

Carnage97
5 1 2 4

avatar image the_batch Jan 03 '19 at 08:34 PM

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.

avatar image Carnage97 Jan 03 '19 at 11:31 PM

I mean the character classalt text

hopefully that helped

capture.png (44.9 kB)
avatar image the_batch Jan 04 '19 at 12:53 AM

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.

avatar image Carnage97 Jan 07 '19 at 11:29 PM

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 alt text

help1.png (134.6 kB)
avatar image Tuerer Jan 04 '19 at 01:14 PM

@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.

avatar image ThompsonN13 Jan 08 '19 at 12:21 AM

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.

alt text

capture.png (483.3 kB)
(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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.

more ▼

answered Jan 08 '19 at 12:34 AM

avatar image

const_iterator
1 1 3

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question