UE4 | Inventory for Multiplayer # 1 | Data Store on DataAsset
UE4 | Inventory for Multiplayer # 2 | Connect Blueprint to C ++
UE4 | Inventory for Multiplayer # 3 | Interaction structure
UE4 | Inventory for Multiplayer # 4 | Creating and connecting a container
UE4 | Inventory for multiplayer # 5 | Information transfer between Server and Client
In this article we will look at the inventory structure, which I applied to my multiplayer project. This section is quite small and does not contain the code.
The inventory itself is a component used not only for Character , but also for any object in the game, which according to the scenario can be a repository for objects. For example: chest, drawer, box, cabinet, etc.
This component contains a TArray , whose elements store the minimum necessary information:
In this inventory structure there are no references to the objects themselves, because after saving and loading the game, they will refer to areas that already store other data. Thus, some kind of tool is needed that could restore (respawn) all objects after loading the game. This is where DataAsset comes to the rescue , which is always available on the server side (since in our case we connected it via GameMode ) and is ready to help place the object on the stage.
The component of the inventory also contains the logic of removing and adding the required number of objects, the logic of filling slots. All functions launched in the container should work only on the server side.
The unique properties of the object, such as additional components , and the logic can be easily configured using C ++ and / or Blueprint .
In the next section, I will show how you can connect the created component to Character or any other object.
Any constructive criticism is welcome. Preferably backed up with suggestions.
PS The first two articles added explanatory images.
Source: https://habr.com/ru/post/419347/
All Articles