Spawn DecalActor when static object is Hit

This commit is contained in:
baz 2023-10-12 23:03:59 +01:00
parent 589592927f
commit b4fb8f7761
1 changed files with 15 additions and 0 deletions

View File

@ -381,6 +381,21 @@ void APlayerCharacter::ProcessHits(TArray<FHitResult> hits)
} }
} }
} }
auto staticMeshComponent = Hit.GetActor()->GetComponentByClass<UStaticMeshComponent>();
if (staticMeshComponent && !staticMeshComponent->IsSimulatingPhysics() && CurrentWeapon->GetDecalActor())
{
FTransform transform;
transform.SetLocation(Hit.ImpactPoint);
auto decalActor = GetWorld()->SpawnActor<ADecalActor>(CurrentWeapon->GetDecalActor(), transform,
SpawnParameters);
auto rot = Hit.ImpactNormal.Rotation();
rot.Roll += 90.0f;
rot.Yaw += 180.0f;
decalActor->SetActorRotation(rot);
}
} }
} }
} }