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?
asked Oct 29 '14 at 04:39 PM in C++ Programming
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:
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.
answered Oct 29 '14 at 06:30 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here