My solution to this is to iterate amongst all actors of a given class then calculate the distance for each actor that matches your criteria and apply damage here.
float ExplosionRadius = 200.0f;
float ExplosionDamage = 25.0f;
for ( TActorIterator<AMyCharacter> aItr(GetWorld()); aItr; ++aItr )
{
float distance = GetDistanceTo(*aItr);
if (distance <= ExplosionRadius)
{
UGameplayStatics::ApplyDamage(*aItr, ExplosionDamage,
GetInstigatorController(), this, UDamageType::StaticClass());
}
}
Don’t forget to configure your target actor class to take damage as well ![]()