MyCharacter.h
UPROPERTY(Replicated, EditDefaultsOnly)
float Health;
MyCharacter.cpp
float AMyCharacter::TakeDamage(float Damage, FDamageEvent const& DamageEvent, AController* EventInstigator, AActor* DamageCauser)
{
Health -= Damage;
return Damage;
}
When i start my game and call TakeDamage from server, then It's working well. But if i call TakeDamage from client, it doesn't reflect Health at server. So i tried to make RPC function MulticastRPCTakeDamage(float Damage)
and replace Health -= Damage.
float AMyCharacter::TakeDamage(float Damage, FDamageEvent const& DamageEvent, AController* EventInstigator, AActor* DamageCauser)
{
MulticastRPCTakeDamage(Damage);
return Damage;
}
I also tried ServerRPCTakeDamage
and ClientRPCTakeDamage
. But it's not working well. Help me!