diff --git a/Source/Nakatomi/ExplosiveActor.cpp b/Source/Nakatomi/ExplosiveActor.cpp index 1413bf6..0bc8f37 100644 --- a/Source/Nakatomi/ExplosiveActor.cpp +++ b/Source/Nakatomi/ExplosiveActor.cpp @@ -48,14 +48,17 @@ void AExplosiveActor::Explode() for (FOverlapResult Overlaps : outOverlaps) { - UHealthComponent* healthComponent = Overlaps.GetActor()->GetComponentByClass(); - - if (healthComponent) + if (Overlaps.GetActor()) { - float distance = FVector::Distance(ActorToWorld().GetLocation(), - Overlaps.GetActor()->ActorToWorld().GetLocation()); - float scale = 1.f - (distance / ExplosionRadius); - healthComponent->TakeDamage(Overlaps.GetActor(), scale * MaxDamage, nullptr, nullptr, this); + UHealthComponent* healthComponent = Overlaps.GetActor()->GetComponentByClass(); + + if (healthComponent) + { + float distance = FVector::Distance(ActorToWorld().GetLocation(), + Overlaps.GetActor()->ActorToWorld().GetLocation()); + float scale = 1.f - (distance / ExplosionRadius); + healthComponent->TakeDamage(Overlaps.GetActor(), scale * MaxDamage, nullptr, nullptr, this); + } } }