diff --git a/Source/Nakatomi/EnemyAIController.cpp b/Source/Nakatomi/EnemyAIController.cpp index 8aaefa0..2695b22 100644 --- a/Source/Nakatomi/EnemyAIController.cpp +++ b/Source/Nakatomi/EnemyAIController.cpp @@ -104,10 +104,12 @@ void AEnemyAIController::OnDeath(FDamageInfo info) if (enemy->DefaultWeaponInventory.Num() > 0) { // TODO: This can sometimes crash, need to investigate - auto weaponPickup = GetWorld()->SpawnActor(); - weaponPickup->SetActorLocation(enemy->GetActorLocation()); - weaponPickup->SetWeapon(enemy->DefaultWeaponInventory[enemy->GetCurrentInventorySlot()]); - weaponPickup->SetWeaponProperties(*enemy->CurrentWeapon->GetWeaponProperties()); + if (auto weaponPickup = GetWorld()->SpawnActor()) + { + weaponPickup->SetActorLocation(enemy->GetActorLocation()); + weaponPickup->SetWeapon(enemy->DefaultWeaponInventory[enemy->GetCurrentInventorySlot()]); + weaponPickup->SetWeaponProperties(*enemy->CurrentWeapon->GetWeaponProperties()); + } } }