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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

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!!!! :)

Product Version: Not Selected
Tags:
more ▼

asked Oct 11 '14 at 01:51 AM in Blueprint Scripting

avatar image

Comixian
19 5 8 9

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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.

more ▼

answered Oct 11 '14 at 02:30 AM

avatar image

Erasio
5.9k 291 86 293

avatar image Comixian Oct 11 '14 at 06:46 PM

Like this? Its not working so I think I'm doing something wrong :(

avatar image Erasio Oct 11 '14 at 10:44 PM

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 ;)

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

avatar image Comixian Oct 12 '14 at 05:27 AM

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

avatar image Erasio Oct 12 '14 at 10:42 AM

Try a "Print String" Directly after the "on overlap".

avatar image Comixian Oct 12 '14 at 03:07 PM

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 :)

avatar image Erasio Oct 12 '14 at 03:35 PM

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

avatar image Comixian Oct 12 '14 at 03:55 PM

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?

avatar image Erasio Oct 12 '14 at 03:57 PM

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

avatar image Comixian Oct 12 '14 at 04:55 PM

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 :( :( :(

Thank you for your patience

avatar image Erasio Oct 12 '14 at 05:03 PM

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.

avatar image Comixian Oct 12 '14 at 05:23 PM

OK OK OK, I finally got it working!!! Thank you for that!!! :D 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! :)

avatar image Erasio Oct 12 '14 at 10:40 PM

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 ;)

(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