Spawn Particle System at Impact Point on a static object

This commit is contained in:
baz 2023-10-15 20:00:34 +01:00
parent b4fb8f7761
commit ca617a8a3c
3 changed files with 23 additions and 0 deletions

View File

@ -396,6 +396,19 @@ void APlayerCharacter::ProcessHits(TArray<FHitResult> hits)
rot.Yaw += 180.0f;
decalActor->SetActorRotation(rot);
}
if (staticMeshComponent && !staticMeshComponent->IsSimulatingPhysics() &&
CurrentWeapon->GetImpactParticleSystem())
{
FTransform transform;
transform.SetLocation(Hit.ImpactPoint);
UGameplayStatics::SpawnEmitterAtLocation(this,
CurrentWeapon->GetImpactParticleSystem(),
transform.GetLocation(),
FRotator::ZeroRotator,
true);
}
}
}
}

View File

@ -125,6 +125,11 @@ TSubclassOf<ADecalActor> AWeapon::GetDecalActor()
return DecalActor;
}
UParticleSystem* AWeapon::GetImpactParticleSystem()
{
return ImpactParticleSystem;
}
TSubclassOf<class ANakatomiFieldSystemActor> AWeapon::GetFieldSystemActor()
{
return FieldSystemActor;

View File

@ -55,6 +55,9 @@ protected:
UPROPERTY(EditDefaultsOnly)
TSubclassOf<class ADecalActor> DecalActor;
UPROPERTY(EditDefaultsOnly)
UParticleSystem* ImpactParticleSystem;
public:
// Sets default values for this actor's properties
AWeapon();
@ -101,4 +104,6 @@ public:
TSubclassOf<AWeaponThrowable> GetWeaponThrowableTemplate();
TSubclassOf<class ADecalActor> GetDecalActor();
UParticleSystem* GetImpactParticleSystem();
};