Should my character's inventory exist only on the Server?

Hello, i’m doing a multiplayer game and would like to know if i should replicate my inventory to the Autonomous client or it should only exist in the Server? I’m asking this because right now when a client presses Reload i play the reload animation immediately for fast responsiveness and only on the server do i check if there is a next magazine to reload. The problem is if i start reloading on the client and the server comes to the conclusion that there is no more magazines. I can send a StopReload from Server to Client to stop the reloading animation, but that is not the best user experience because he will see part of the animation when the StopReload reaches the client. So to avoid that, should i replicate the inventory on the Autonomous client for him to be able to perform the magazine verification or should i call the Server first and only when the server responds and confirms there is a magazine can i play the reload animation? Thank you.

P.S: Do SimulatedProxy clients need to have the inventory also? or they just play animations?

Of course you can replicate all of your inventory from client to server. But you cannot change value of those variables on the client side, the objects are critical to gameplay and should be spawned on the server side - this means that they have an authority there. You can read information about how much ammo has left on the client side to avoid RPC ping-pong. Also, if you replicate all of your inventory, you can show all of it’s elements in HUD.

If you don’t want to replicate all invetory, use this pattern:

  1. Player controller handles input on Client side and makes RPC call to it’s authority on server: Reload().
  2. Reload logic on server decides if you have more ammo or not.
  3. Let’s say you don’t have any ammo, then server can call RPC to your client OnNoAmmo() wich will cause HUD to display “No ammo” message.
  4. On the other hand if you have ammo, you can call RPC to all clients (multicast) that will cause your animation to play, and be visible by others.

As a compromise, you can replicate only a part of your inventory let’s say ammount variable for each weapon. You can check it then on client side before calling Reload(). If you have enough ammo, then call Reload() RPC to server and start animation. If you want others to see your reload animation, then server should call multicast RPC.

I Hope it helped.

Btw. RPC are explained well here: https://docs.unrealengine.com/latest/INT/Gameplay/Networking/Replication/RPCs/index.html

Yes i need to show my HUD with the inventory, so i have to replicate it. If i do the animation client side and then on the server i call the client multicast method to update all other clients, that will also run on the autonomous client that already was animating, how do i prevent him from playing the animation again? Right now the only way i can think of is by doing this:

void AMyCharacter::ClientReloadMulticast_Implementation()
{
     if(Role == ROLE_Autonomous) // or if(bIsReloading)
          return;

     PlayReloadAnim();    // Executes only on the simulated clients
}

The simulated clients also don’t need to know the inventory and what magazine you have, they just do blindly what the server tells them right?

  1. I had no case like this, but my first idea is to check ownership of your pawn.
  2. Yes. But they in fact know… if you replicate an actor from server, it would be replicated to all clients.
  1. What do i check the owner with? The autonomous client is not the owner of the pawn so i not sure if on that function i can check that condition like that.
  2. If i set the replication condition to owner only it will not replicate to the simulated clients right?