Hello,
I have a second question related to the networking. If i run this on server it works fine, but for a Client if I shot a player it doesn’t change his current health. The code doesn’t enter in TakeDamageRPC_Implementation function.The health variable is replicated.
if (AMyCharacter* EnemyPlayer = dynamic_cast<AMyCharacter*>(Hit.GetActor())) {
EnemyPlayer->TakeDamage(DealtDamage, DamageEvent, OwningPlayer->GetController(), this);
}
float AMyCharacter::TakeDamage(float DamageAmount, struct FDamageEvent const & DamageEvent, AController * EventInstigator, AActor * DamageCauser)
{
//works fine until here
TakeDamageRPC(DamageAmount);
return Super::TakeDamage(DamageAmount, DamageEvent, EventInstigator, DamageCauser);
}
UFUNCTION(Server, Reliable, WithValidation)
void TakeDamageRPC(float DamageTaken);
void AMyCharacter::TakeDamageRPC_Implementation(float DamageTaken) {
// reduce health implementation
}
Thanks!