From 9ece07b011327783d2b9192572a22005e7e97280 Mon Sep 17 00:00:00 2001 From: baz Date: Mon, 18 Sep 2023 02:29:18 +0100 Subject: [PATCH] Move feteching of HealthComponent outside of if statement --- Source/Nakatomi/ExplosiveActor.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/Nakatomi/ExplosiveActor.cpp b/Source/Nakatomi/ExplosiveActor.cpp index 70103b8..1413bf6 100644 --- a/Source/Nakatomi/ExplosiveActor.cpp +++ b/Source/Nakatomi/ExplosiveActor.cpp @@ -48,7 +48,9 @@ void AExplosiveActor::Explode() for (FOverlapResult Overlaps : outOverlaps) { - if (auto healthComponent = Overlaps.GetActor()->GetComponentByClass()) + UHealthComponent* healthComponent = Overlaps.GetActor()->GetComponentByClass(); + + if (healthComponent) { float distance = FVector::Distance(ActorToWorld().GetLocation(), Overlaps.GetActor()->ActorToWorld().GetLocation());