C++ TakeDamage / Inflict Damage
anyone can explain me, how my character can TakeDamage from another player and InflictDamage to another player in a FPS game, i've created a CharacterClass that can TakeDamage with this Function :
TakeDamage(float Damage, struct FDamageEvent const& DamageEvent, class AController* EventInstigator, class AActor* DamageCauser), but now how can i inflict damage to another player, i've also created a ProjectileClass and a WeaponClass.
asked Mar 17 '16 at 06:15 PM in C++ Programming
if somebody wonders what is the signature for TakeDamage(), here is what you put in your .h file.
also for the sake of god and Tim.S , please don't type "struct" and "class" before function variable types
answered Sep 24 '17 at 01:56 PM
I'm adding a snippet here from my Exploding Barrel implementation:
The params are as follows:
So, based on some event "Explosion" in your actor that wants to deal damage, I call a global function "ApplyRadialDamage" which broadcasts this damage event to all objects within a certain radius. For each of the objects found, it will call their TakeDamage() function.
E.g. then in my Character class cpp:
The first part is mainly relevant to you - here I get some details about the damage event that was received, and then you can use that to do what you require. In my case I play a camera shake animation.
Please let me know if anything is unclear and I'll add some more details.
answered Mar 18 '16 at 10:07 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here