Spawn ParticleSystem OnHit NakatomiCharacter

This commit is contained in:
baz 2024-03-07 17:16:15 +00:00
parent e1ae4f60a8
commit ed3747037c
2 changed files with 24 additions and 0 deletions

View File

@ -144,6 +144,18 @@ void AEnemyCharacter::ProcessHits(TArray<FHitResult> hits, FVector dir)
healthComponent->TakeDamage(Hit.GetActor(), CurrentWeapon->GetWeaponProperties()->WeaponDamage, nullptr,
GetController(), this);
}
auto character = Cast<ANakatomiCharacter>(Hit.GetActor());
if (character && character->GetOnDamagedHitNiagaraSystem())
{
UNiagaraFunctionLibrary::SpawnSystemAtLocation(this,
character->GetOnDamagedHitNiagaraSystem(),
Hit.ImpactPoint,
dir.MirrorByVector(Hit.ImpactNormal).Rotation(),
FVector(1),
true);
}
}
auto staticMeshComponent = Hit.GetActor()->GetComponentByClass<UStaticMeshComponent>();

View File

@ -406,6 +406,18 @@ void APlayerCharacter::ProcessHits(TArray<FHitResult> hits, FVector dir)
{
healthComponent->TakeDamage(Hit.GetActor(), CurrentWeapon->GetWeaponProperties()->WeaponDamage, nullptr,
GetController(), this);
auto character = Cast<ANakatomiCharacter>(Hit.GetActor());
if (character && character->GetOnDamagedHitNiagaraSystem())
{
UNiagaraFunctionLibrary::SpawnSystemAtLocation(this,
character->GetOnDamagedHitNiagaraSystem(),
Hit.ImpactPoint,
dir.MirrorByVector(Hit.ImpactNormal).Rotation(),
FVector(1),
true);
}
if (!healthComponent->GetIsDead())
{