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,10 +265,18 @@ void APlayerCharacter::ProcessHits(TArray<FHitResult> hits)
SpawnParameters.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn; SpawnParameters.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
// Spawn field actor // Spawn field actor
if (CurrentWeapon->GetFieldSystemActor())
{
FTransform transform; FTransform transform;
transform.SetLocation(Hit.ImpactPoint); transform.SetLocation(Hit.ImpactPoint);
auto field = GetWorld()->SpawnActor<AFieldSystemActor>(CurrentWeapon->GetFieldSystemActor(), transform, SpawnParameters); auto field = GetWorld()->SpawnActor<AFieldSystemActor>(CurrentWeapon->GetFieldSystemActor(), transform, SpawnParameters);
if (field)
{
field->Destroy();
}
}
if (Hit.GetActor()) if (Hit.GetActor())
{ {
if (Hit.GetActor()->ActorHasTag("Enemy")) if (Hit.GetActor()->ActorHasTag("Enemy"))