From 55ec2cbfdacf2763becd9a1187631519a32decf8 Mon Sep 17 00:00:00 2001 From: baz Date: Sat, 15 Feb 2025 00:25:29 +0000 Subject: [PATCH] Make transform calculations only calculate if enemy is loaded --- Source/vampires/VampireGameMode.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Source/vampires/VampireGameMode.cpp b/Source/vampires/VampireGameMode.cpp index b27850f..fc01b96 100644 --- a/Source/vampires/VampireGameMode.cpp +++ b/Source/vampires/VampireGameMode.cpp @@ -71,9 +71,6 @@ void AVampireGameMode::SpawnEnemy() break; } - SpawnLocation.Z = PlayerCharacter->GetActorLocation().Z; - FTransform Transform; - Transform.SetLocation(SpawnLocation); if (AActor* enemy = GetEnemyObjectPoolManager_Implementation()->GetObject()) { @@ -81,7 +78,11 @@ void AVampireGameMode::SpawnEnemy() { IEnemyable::Execute_LoadDataFromDataAsset(enemy, EnemyDataAssets[FMath::RandRange(0, EnemyDataAssets.Num() - 1)]); + SpawnLocation.Z = PlayerCharacter->GetActorLocation().Z; + FTransform Transform; + Transform.SetLocation(SpawnLocation); enemy->SetActorTransform(Transform); + float CapsuleRadius = IEnemyable::Execute_GetCapsuleRadius(enemy); FVector Direction = SpawnLocation - PlayerCharacter->GetActorLocation(); Direction.Normalize();