Alternative Health Method

Hello Everyone, I am sharing the alternative method for health.
The below is the blueprint where it does the IsDead check first before setting the health, this is because when the player dies the health goes into minus. This way the health will never go lower than 0.

Here is the C++ code for the health system using TakeDamage. Hopeful these are both useful.


  virtual float TakeDamage(float Damage, const FDamageEvent &DamageEvent, AController *EventInstigator, AActor *DamageCauser);


float AMannequin::TakeDamage(float Damage, const FDamageEvent &DamageEvent, AController *EventInstigator, AActor *DamageCauser)
   if(Health > HealthZero) 
	{ Health = Health - Damage; }

    if (Health == HealthZero)
	{ DetachFromControllerPendingDestroy(); }
    return Health;

Privacy & Terms