Ragdolling in Multiplayer

Hello there guys,

I’m having some troubles with ragdolling in a multiplayer session.

When I apply the following code in my gamemode cpp, only the server session ragdolls the players who should be ragdolled, the client doesn’t seem to apply the code.

for (FConstPlayerControllerIterator Iterator = GetWorld()->GetPlayerControllerIterator(); Iterator; ++Iterator)
	{
		APlayerController* PlayerController = *Iterator;
		if (PlayerController)
		{

			ASurvivalCharacter * pPlayer = Cast<ASurvivalCharacter>(PlayerController->GetPawn());

			if (pPlayer && !pPlayer->IsPendingKill())
			{
				
				pPlayer->GetMesh()->SetAllBodiesSimulatePhysics(true); // doesn't apply on client
				pPlayer->GetMesh()->SetSimulatePhysics(true); // doesn't apply on client
				pPlayer->GetMesh()->WakeAllRigidBodies(); // doesn't apply on client
				PlayerController->UnPossess(); // Is applied
			}
			
		}
	}

Is there something I’m missing?

Do I need to replicate the functions I’ve called?

Example Image:

https://cloud.effectgc.eu/index.php/s/1ieFY3uLWLQiQTV

I can’t quite remember, but I believe that the game mode object only lives on the server. So that means you’ll need to create a member function on your ASurvivalCharacter that get’s called on the server but executed on the client. You do that by declaring a function as an RPC with the Client keyword.

// Inside ASurvivalCharacter class declaration
UFUNCTION(Client)
void DoTheRagDoll();