I want to create multiple damage types (i.e normal damage, poison, slowdown, stun, fear…), but I don’t know what is the best way to do it.
I have different functions in which I have the implementation of the different damage types, but I don’t know where call them, neither how works the parameter DamageType-DamageEvent. I also read about bind delegates with OnTakeAnyDamage, but I cannot make it run.
Can someone explain what is the best way to handle that different types of damage?
DamageType it is class that used to handle type of damage that was applied to some actor. For example you can have different damage types for your weapon (simple bullets, incendiary bullets, etc.)
This function pass your damage type class to the TakeDamage function through EventDamage parameter.
// process machine gun hit function
UGameplayStatics::ApplyPointDamage(HitResult.Actor.Get(), ImpactDamage, ShootDir, HitResult, MyController.Get(), this, UDamageType_Gatling::StaticClass());
// Take damage function
float AMyPawn::TakeDamage(float Damage, struct FDamageEvent const& DamageEvent, class AController* EventInstigator, class AActor* DamageCauser)
{
…
DamageEvent.DamageTypeClass;
…
}
Hi,
What I want is something like bind a function inside my projectile class, so I can have a lot of different projectiles which have different behaviour, then, execute that behaviour on the TakeDamage, so I can avoid an endless switch case inside the TakeDamage. Can i do that? or I’m asking about magic? xD