Isn’t the Onrep function(Cpp btw) supposed to run in both on client and server? I thought it was supposed to take care of simple variable replication, but I can’t seem to get it working on the server side, and have to make separate functions for all of them, which seems unnecessary. Am I missing something?
Here’s my code, can I simplify it?:
void APlayerCharacter::SetIsDead(bool value) { // for ease of use
if (HasAuthority()) {
SetIsDead_Server(value);
}
else {
SetIsDead_Client(value);
}
}
void APlayerCharacter::SetIsDead_Client_Implementation(bool value) // client, reliable
{
SetIsDead_Server(value);
}
void APlayerCharacter::SetIsDead_Server_Implementation(bool value) /* server, reliable, why doesn''t it work without this? */
{
bIsDead = value;
RetargetMesh->SetSimulatePhysics(value);
}
void APlayerCharacter::OnRep_IsDead() // bool IsDead , replicatedusing = onrep_isdead
{
RetargetMesh->SetSimulatePhysics(value);
}