Move feteching of HealthComponent outside of if statement

This commit is contained in:
baz 2023-09-18 02:29:18 +01:00
parent ff8e947a4e
commit 9ece07b011
1 changed files with 3 additions and 1 deletions

View File

@ -48,7 +48,9 @@ void AExplosiveActor::Explode()
for (FOverlapResult Overlaps : outOverlaps) for (FOverlapResult Overlaps : outOverlaps)
{ {
if (auto healthComponent = Overlaps.GetActor()->GetComponentByClass<UHealthComponent>()) UHealthComponent* healthComponent = Overlaps.GetActor()->GetComponentByClass<UHealthComponent>();
if (healthComponent)
{ {
float distance = FVector::Distance(ActorToWorld().GetLocation(), float distance = FVector::Distance(ActorToWorld().GetLocation(),
Overlaps.GetActor()->ActorToWorld().GetLocation()); Overlaps.GetActor()->ActorToWorld().GetLocation());