How to make an actor deal damage and have another actor take damage?

Hello,

I was wondering how to do two things in Blueprint Scripting:

  1. How do I make an actor, like Spikes in a wall, deal damage

AND

  1. How do I make another actor, like a player, receive that damage?

I have only found answers for making an actor receive damage, but not to assign an actor to give damage. Please help me understand this!!! Thank you!!! :slight_smile:

There are two simple nodes.

“Any damage” and “Apply damage”.

Any damage will receive all types of damage (unreal offers a few out of the box) and Apply damage will trigger that event on the other actor.

Now to fire this event you simply need some kind of hitbox and once it does collide or overlap with something, take the resulting “Other Actor” and pull a line from that pin to your “Apply Damage” node.

Any Damage will then receive an input and you can handle your HP in the actor which just got hit.

So Apply damage in your bullet or inside of your spikes blueprint. Any Damage in your Character or whatever should get hit.

Like this? Its not working so I think I’m doing something wrong :frowning:

Two things.

First please check with a “Print String” if “Event Any Damage” is receiving any input at all.

And secondly look in your spike settings if it does fire “Overlap” events. There is a setting for each part where you can set if it should or should not do so meaning it can potentially just not fire at all. (While you’re at it check this for your character as well. Better safe than sorry :wink:

This is basically the correct way to do it though. However you might want to subtract the HP before checking because right now it is possible (if the character gets more than 1 damage) that he has negative HP… which is not really ideal to say the least ;D

I messed around with what you said but still nothing. Any other ideas? Thanks! :slight_smile:

Try a “Print String” Directly after the “on overlap”.

Still nothing. Would it be possible to get a screenshot? I apologize for asking for help so much. It’s my first time using UE4 :slight_smile:

If there is still nothing then you did not make a mistake with the damage system but with how you set up your actor.

You somewhere have not checked the “Overlap” checkbox for your component or it is set to “Block” as collision (this may be called, dynamic actor or whatever but after all it would block whatever causing it to not overlap).

My wild guess would be you did not setup a hitbox (or at least not properly).

It looks like you only have the spike mesh. If this one is set to collide with everything (since it is a part of your level. Nothing should pass through) it can not possibly overlap with anything since everything is just colliding with it and bouncing off.

Try a “Event Hit” and check with a “Print String” node if there is a signal.

Or go directly one step ahead and set up a “Box” in your components. Place it where the player should be damaged (at least slightly above your mesh) and set it to “Overlap All”.

I’ll try what you suggest but in the meantime:

I setup my character as a PaperCharacter and my spikes as a PaperSpriteActor (its a 2D game) could that have anything to do with it?

Maybe. I don’t know the defaults but the things you have to look at are the same.

As long as it’s not overlapping a property is set incorrectly or you are not walking in it (or it’s hitbox).

OK … Finally I got something:

I got event hit to trigger when the character touches it. I’m not sure what to do next though. I’m really sorry for all the questions. I wish I could find an expert around where I live and have them show me this stuff :frowning: :frowning: :frowning:

Thank you for your patience

Well you had the rest already didn’t you?

“Other Actor” into “Apply Damage” and in your Spikes “Any damage” and then do stuff with your HP.

OK OK OK, I finally got it working!!! Thank you for that!!! :smiley: But now I need to fine tune things. I have one more question:

If the actor dies, his camera dies too, so how do I change from the actor camera to another camera if the actor dies? Thank you so much! :slight_smile:

You mustn’t destroy the controller but only the pawn (basically your player character).

Set your camera to something else (like a topdown view of the scene or something) and then after you spawned a new player / actor possess this one again.

If you have trouble with this you might want to create a new question though.

And remember to chose the answer as correct again since it deselects it every time a comment is added to it… and people should know this is solved for you :wink: