Compare commits

...

3 Commits

5 changed files with 36 additions and 2 deletions

Binary file not shown.

View File

@ -144,6 +144,18 @@ void AEnemyCharacter::ProcessHits(TArray<FHitResult> hits, FVector dir)
healthComponent->TakeDamage(Hit.GetActor(), CurrentWeapon->GetWeaponProperties()->WeaponDamage, nullptr, healthComponent->TakeDamage(Hit.GetActor(), CurrentWeapon->GetWeaponProperties()->WeaponDamage, nullptr,
GetController(), this); 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>(); auto staticMeshComponent = Hit.GetActor()->GetComponentByClass<UStaticMeshComponent>();

View File

@ -257,6 +257,11 @@ bool ANakatomiCharacter::GetCrouched()
return false; return false;
} }
UNiagaraSystem* ANakatomiCharacter::GetOnDamagedHitNiagaraSystem()
{
return OnDamagedHitNiagaraSystem;
}
void ANakatomiCharacter::CalculateHits(TArray<FHitResult>* hits, FVector* dir) void ANakatomiCharacter::CalculateHits(TArray<FHitResult>* hits, FVector* dir)
{ {
} }

View File

@ -45,6 +45,9 @@ public:
UPROPERTY(EditDefaultsOnly) UPROPERTY(EditDefaultsOnly)
TArray<UAnimMontage*> OnDamagedHitAnimMontages; TArray<UAnimMontage*> OnDamagedHitAnimMontages;
UPROPERTY(EditDefaultsOnly)
UNiagaraSystem* OnDamagedHitNiagaraSystem;
protected: protected:
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Meta = (AllowPrivateAccess = "true")) UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Meta = (AllowPrivateAccess = "true"))
UNakatomiCMC* NakatomiCMC; UNakatomiCMC* NakatomiCMC;
@ -115,6 +118,8 @@ public:
UFUNCTION(BlueprintCallable) UFUNCTION(BlueprintCallable)
bool GetCrouched(); bool GetCrouched();
UNiagaraSystem* GetOnDamagedHitNiagaraSystem();
protected: protected:
virtual void CalculateHits(TArray<FHitResult>* hits, FVector* dir); virtual void CalculateHits(TArray<FHitResult>* hits, FVector* dir);

View File

@ -407,6 +407,18 @@ void APlayerCharacter::ProcessHits(TArray<FHitResult> hits, FVector dir)
healthComponent->TakeDamage(Hit.GetActor(), CurrentWeapon->GetWeaponProperties()->WeaponDamage, nullptr, healthComponent->TakeDamage(Hit.GetActor(), CurrentWeapon->GetWeaponProperties()->WeaponDamage, nullptr,
GetController(), this); 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()) if (!healthComponent->GetIsDead())
{ {
OnEnemyHit.ExecuteIfBound(); OnEnemyHit.ExecuteIfBound();