Damage: Event onDamage won't fire : Need help understanding what is wrong

Hello,

I created a third person template project, and a default level.
I created an Actor BP with this event graph and a static mesh attached which collision has been generated using the 26DOP Simplified Collision to the mesh.
I’m trying to apply damage on the actor when the player hits it.

When I check the blueprint while running the game, the debug pin is executed and the return value for the damage is 1000.
However, none of the 3 damage event handler are triggered.

Can someone help me figure out what is wrong ?

It doesn’t seem to be clear what’s causing damage to what.

The left hand part should be in the projectile, the right hand side needs to be in the player ( if that’s what you’re causing damage to? )

But even then, having the player as the instigator doesn’t really make sense.

  • in the player BP:

image

  • in the object to be damaged:

image

@ClockworkOcean
The damage causer is the ThirdPersonCharacter itself, the hit event is handeld inside the Actor BP which is also the one one which the damage is applied.
I want the collision event (hit) and the damage event (OnDamage) to be handeld inside the actor bp so he manages his own logic, w/o the ThirdPersonCharacter being aware of what is happening to this actor.
How can I implement this if what I did is wrong ?

@Everynone
Does the ThirdPersonCharacter has to be the one to manage the Hit event, can’t I implement it inside the Actor being hit ?

Does the ThirdPersonCharacter has to be the one to manage the Hit event, can’t I implement it inside the Actor being hit ?

Sure, why not:

  • in the object to be damaged:

The actor applies damage to itself when hit. If you want to ensure it was the player who dealt it:

I think the issue is there:

is the OnTakeAnyDamage_Event something that needs implementation while the event AnyDamage as actually what I was looking for ?

Look for the relevant implementation here:


The event you’ve got up there is probably unregistered - these are useful if you wanted another actor to know that this actor was hit.

So if I understand correctly I should plug the OnTakeAnyDamageEvent at the end of the conditionnal logic of the AnyDamage chain so other actors can listen to this event from outside this blueprint ?

Edit: Realized I’m wrong since it’s an event itself so it has no input pin.
So I guess this event is already implemented but should be used outside this blueprint and this is maybe why it’s not working inside of it to avoid some loop call ?

Not really.

Unreal has a native damage system revolving around Interface communication. That’s the node on the left.

image

The custom event on the right would be used when Event Dispatchers notify other entities that something happened here.

so other actors can listen to this event from outside this blueprint ?

So, in a way, yes but event registration is done differently.


Technically speaking, all you need is this:

image

There isn’t even need to have have Apply / Receive damage. But you may need it to easily calculate damage done.

Thank you for your time and explanations. It’s clearer now to me.

Yeah I wanted to use the engine feature to manage this.

The idea was to have a mining node feature.
Any entity that would hit the actor would perform a given amount of damage which would destroy the actor at some point and spawn some other collectible actors.

I wanted to use the default engine management for health to do that instead of managing myself a health system inside the actor this is why I went with the apply damage implementation, it might be overkill tho.

1 Like

Not an overkill at all, it’s a robust system. It will work well for this and can the extended further if needed. This should be fine:

image

But it’s not a bad idea to let the player damage things. It makes things clearer when its the player who actually decides how much damage they deal - since they may have a tool / weapon / stats that affects this.

But again, there’s too many ways to do this!


UE gotcha: Base Damage cannot be 0.

About the damage inflicted, I thought doing it this way so I can manage having different damage on different actor by the same entity.

So for intance I can check if the colliding actor with the actor is the player then inflict 5 damage to wood but 0 to stone and then check if the colliding actor is the tools and do different damage.

So in case you are still around here, this is what I came up with.
If I can steal a little bit more of your time maybe there is a simplified way of writng the part in comments ? (There is a missing pin between the false and apply damage but you get the idea)

Edit: Graph (The part where I get the data I mean, can I do it without a setter with some sort of validated value ?)

You could and it would work OK for something simple, I’m sure. But even simple things turn into blueprint spaghetti monsters full of circular dependencies.


Consider the following If you ever feel something more in-depth is needed; note the Damage Type Class on the Apply Damage node - think of it as of an agnostic damage processor.

A bit of (working) pseudoscript:

  • the player has equipped a Wooden Hatchet that deals (Wood) Damage Type, and proceeds to run like a maniac at whatever obstacle is in front of them. The hatchet deals some damage, the player adds their own Stat to the result.

  • The Resource Node actor receives the damage:

But… before the damage is applied, the Damage Class gets the chance to process it:


This way all the mundane processing can be moved away from the actors (player, resource, hatchet) that should not ever care about what kind of sparks fly when wood hits metal. This might be an overkill for something simple but when you have 14 types of materials to gather, 10 tools and bunch of data to process… this becomes indispensable.

Not sure I get the idea. What you’ve got looks more than fine. Perhaps that’s why you mean:

Not sure if it makes sense here, though.

Make sense. Thank you for this, it’s a very good example, it will help me implement state. This would be the next step before it becomes a spaghetti bp. :slight_smile:

Thanks for your time and sharing your knowledge, I have to process this and try myself once I have.

Edit: (Double post)
I mean rather than having

equal > or > if > value set > apply damage from get value

switch return value > apply damage from return value

Formulatted correctly I guess some kind of switch operator where I can switch on the class and return a value depending on the case then feed it to the apply point damage.

1 Like

Got it. Ideally, you’d use enumeration in an interface:

I guess you could map and associate some values with their respective classes:

But that does not sound like a sensible approach in the long run. The classes would need to be loaded all the time. All resources need to know about all types… fiddly stuff.

1 Like