Add CameraShake in Player Character on OnDamaged

This commit is contained in:
baz 2025-04-23 02:41:29 +01:00
parent b28395bb72
commit c9c128ba44
2 changed files with 9 additions and 0 deletions

View File

@ -77,6 +77,12 @@ void APlayerCharacter::OnDamaged(FDamageInfo damageInfo)
{ {
UGameplayStatics::PlaySoundAtLocation(GetWorld(), OnDamagedSound, GetActorLocation()); UGameplayStatics::PlaySoundAtLocation(GetWorld(), OnDamagedSound, GetActorLocation());
} }
APlayerController* playerController = UGameplayStatics::GetPlayerController(this, 0);
if (playerController && CameraShake)
{
playerController->ClientStartCameraShake(CameraShake);
}
} }
void APlayerCharacter::OnDeath(FDamageInfo damageInfo) void APlayerCharacter::OnDeath(FDamageInfo damageInfo)

View File

@ -32,6 +32,9 @@ public:
UPROPERTY(EditAnywhere) UPROPERTY(EditAnywhere)
UWidgetComponent* HealthBarWidgetComponent; UWidgetComponent* HealthBarWidgetComponent;
UPROPERTY(EditAnywhere)
TSubclassOf<UCameraShakeBase> CameraShake;
APlayerCharacter(); APlayerCharacter();
protected: protected: