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:
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 :)
asked Nov 18 '14 at 02:25 PM in C++ Programming
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.
Follow this question
Once you sign in you will be able to subscribe for any updates here