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"

How exactly does damage work?

When ever I make a health system I always make a health float in the player blueprint. I know unreal has a damage system and I have the slightest idea on how it works but I still would like to learn how exactly how it works and is there a better way to make a health system? and is there a better way to deal damage without casting to the player or other actors I want to damage?

~Thanks in advance!

Product Version: UE 4.16
more ▼

asked Jun 28 '17 at 10:58 PM in Blueprint Scripting

avatar image

116 9 10 18

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

1 answer: sort voted first

About the Unreal Engine dmg system: there is a ready-to-use event called On Any Damage. This should work istantly with the pain-causing-volumes that you can place in the levels trough the mod panel. Instead if you want to apply damage you just call the function "apply damage" where you actually choose the amount of damage, the damaged actor and the TYPE of dmg (prebuilt system where you can choose and add more kinds of dmg, like fire, frost etc). Better way to communicate with actors without casting depends on your game. If you usually spawn enemies at runtime you can just add a PlayerCharacter variable in the enemy BP and set it as editable and exposed on spawn and wherever you decide to spawn them you will call for get player character (the pure function). If you place enemies into the level you can add a Do once >cast to character>promote the return value to a variable at Event begin play. But really there are many ways to do this. Another system is to create a new Blueprint Interface where you create 2 events like Do dmg and Receive dmg, then you can implement the interface on both actors (player+enemy) in the class settings.

more ▼

answered Jun 28 '17 at 11:30 PM

avatar image

296 7 6 15

avatar image TuXsOrDs Jun 29 '17 at 01:56 AM

I am working on somewhat of a MMORPG and when I have the player damage the target (such as a bear or villager) for determining which one the line hit I use a cast and end up nesting. my method right now if I were to add another enemy, in order to damage that new enemy I would drag off of the cast to the new enemy blueprint and subtract some health, I want a better to damage it than nesting like that with the casting. .alt text

question.png (134.5 kB)
avatar image Vertigo23 Jun 29 '17 at 02:46 AM

casting is not bad. Thing is this way you have to cast for every type of enemy. If you create somethink like BP_MasterEnemy and then you create childs of it for every enemy you will have to cast just once

avatar image Vertigo23 Jun 29 '17 at 02:48 AM

for example let's say that now you create a child actor of your Human class called "human child". That human child is gonna take dmg as long as that cast right there doesn't fail

avatar image Kipplinger Jun 29 '17 at 10:38 AM

As vertigo mentioned what you want to use is the apply damage node and feed that with the targeted enemy's actor ref, then in said enemy bp use a "on any damage" node then simply -> function to check if target is dead. You relay shouldn't do casts like that for the damage system, it will get out of hand very quickly. Also to clarify you need to cast the actor ref I mentioned to a specific instance, you can get that from anything - for example the attack collision.

// gl

avatar image TuXsOrDs Jun 29 '17 at 03:53 PM

The apply damage worked a lot better. and I actually had to rebuild my entire damage system and health system with the apply damage and event any damage. Thank you all very much!

avatar image Vertigo23 Jun 29 '17 at 03:54 PM

you're welcome =)

avatar image TuXsOrDs Jun 29 '17 at 07:05 PM

I have made one master enemy and got everything together that all enemies need. and from then on created a child for each enemy, the master never being used for other than being a master and this made it a lot easier and faster. it also has a lot less bugs too. Once again Thank 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