From b4fb8f7761ab0b65f9c85d639eb7ef0c0900f910 Mon Sep 17 00:00:00 2001 From: baz Date: Thu, 12 Oct 2023 23:03:59 +0100 Subject: [PATCH] Spawn DecalActor when static object is Hit --- Source/Nakatomi/PlayerCharacter.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Source/Nakatomi/PlayerCharacter.cpp b/Source/Nakatomi/PlayerCharacter.cpp index dcecbf4..82ab14b 100644 --- a/Source/Nakatomi/PlayerCharacter.cpp +++ b/Source/Nakatomi/PlayerCharacter.cpp @@ -381,6 +381,21 @@ void APlayerCharacter::ProcessHits(TArray hits) } } } + + auto staticMeshComponent = Hit.GetActor()->GetComponentByClass(); + + if (staticMeshComponent && !staticMeshComponent->IsSimulatingPhysics() && CurrentWeapon->GetDecalActor()) + { + FTransform transform; + transform.SetLocation(Hit.ImpactPoint); + + auto decalActor = GetWorld()->SpawnActor(CurrentWeapon->GetDecalActor(), transform, + SpawnParameters); + auto rot = Hit.ImpactNormal.Rotation(); + rot.Roll += 90.0f; + rot.Yaw += 180.0f; + decalActor->SetActorRotation(rot); + } } } }