Add extra checking for field system spawning

This commit is contained in:
Louis Hobbs 2023-05-29 01:36:05 +01:00
parent a8adf8abfb
commit 7256afd8bf
1 changed files with 11 additions and 3 deletions

View File

@ -265,9 +265,17 @@ void APlayerCharacter::ProcessHits(TArray<FHitResult> hits)
SpawnParameters.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
// Spawn field actor
FTransform transform;
transform.SetLocation(Hit.ImpactPoint);
auto field = GetWorld()->SpawnActor<AFieldSystemActor>(CurrentWeapon->GetFieldSystemActor(), transform, SpawnParameters);
if (CurrentWeapon->GetFieldSystemActor())
{
FTransform transform;
transform.SetLocation(Hit.ImpactPoint);
auto field = GetWorld()->SpawnActor<AFieldSystemActor>(CurrentWeapon->GetFieldSystemActor(), transform, SpawnParameters);
if (field)
{
field->Destroy();
}
}
if (Hit.GetActor())
{