How exactly does damage work?

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

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!

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.

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

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

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

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!

you’re welcome =)

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!