How should i replicate my Inventory?

I’m trying to replicate the inventory and the actions that i can do with it (drop, stack, split, and so on). Taking the drop item as an example, i have a Inventory::DropItem(Item, Quantity) method that checks if the item is stacked it calls the Item::Drop() method x amount of times to show the actor, enable collisions and throw it into the world. If it’s not stacked it only calls that method for the main item. Right now i’m only replicating the inventory to the owner, so the simulated clients have the value of None. When the user right clicks the item and clicks drop he calls Inventory::ServerDropItem(Item, Quantity) which calls the local version to drop it on the server. The problem is that i need the clients to execute those Item::Drop() methods because the visibility and collision settings are not replicated. So i only see 2 possible approaches to this problem:

  • The server is the only one that runs the Drop logic and instead of Item::Drop() it executes a Item::ClientDrop() method that is netmulticast and runs on the server also. This way the clients don’t need to know the inventory to be replicated and execute the only part that they need to run.

  • Execute the Drop logic on both the server and the clients, but this means that i have to replicate everything to the clients so that they have the same information as the server and run the exact same flow.

In general what i’m asking is, should the clients (especially the simulated) be completely oblivious of the values and run as minimalistic as possible? Or should they be more aware of the variables and run almost the same logic as the server?

Thank you :slight_smile:

if you want dynamic visibility, updated for everyone to see, it should be a replicated boolean. a multicast function setting the visibility would go out of sync if the event occurred from a great distance due to net relevancy, leaving your object invisible to people who just showed up. collision shouldn’t need to be replicated to the client, it can collide on the server, with the position of the actor replicated to the client.

clients are like alcoholic thieves. let them see what you have in stock, but don’t let them use anything without asking. a client can ask for a drink, the server can check if they had enough, and then the server can decide if the client can handle another drink. if you allow the client to help themselves, they will steal all of your stuff and ruin your business.

Hahahaha. What a great analogy.