Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

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 :)

Product Version: Not Selected
more ▼

asked Nov 18 '14 at 02:25 PM in C++ Programming

avatar image

6k 161 129 304

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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.

more ▼

answered Nov 20 '14 at 06:19 PM

avatar image

9.6k 320 205 449

avatar image ogrewizardninja Nov 20 '14 at 07:12 PM

Hahahaha. What a great analogy.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question