Inventory UI with UMG Networking
Does anyone know how to get this to work over the network?
I would like to use this as a starting point for my inventory but need to get it working over the network before i can really get started.
UMG is not made to work with Unreal's networking feature so simply replicating that is out of the question.
You have to proxy everything through an actor with permission to send RPCs to the server. The easiest one would be your player controller although you could use your pawn or even a different actor altogether.
This actor stores a list of items that you own. You can either have an array of integers that point towards a global list of items or you can have an array of item objects. We will go with the second approach. What you can do now is controlling your inventories on the server and the client separate from each other. You handle all item logic on the server and send RPCs to all clients with the given actor (the server and the client owning our controller in our case). A simple version of such an inventory would look like this:
An example scenario: Your character finds a lighter and walks into it thereby picking it up. The client ignores this event but the server now calls AddItem with the lighter class on the character's controller. It will then send an RPC to the clients and itself to append an instance of the item to the Items array. We also sent the index to ensure that the array on client and server is always in sync. Now you can follow the tutorial and once the user wants to use the lighter we pass in the index of the lighter within the array to the UseItem function where it will be executed on the server. Done. After every item add or item remove event you can update your inventory widget.
Note that this is a very simple menu system and usually you would want to check if the passed in item index is valid and if the item associated with it can be used at the moment etc. But for demonstration purposes this will do.
If you have any questions just ask ahead.
answered Nov 26 '16 at 06:54 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here