Multiplayer Functionality

The Inventory has been enhanced by Multiplayer Functionality

First steps to make it running:

  • Open the scene “InventMultiplayerPlayground”
  • Goto File–>Build Settings and click “Add Open Scene”. This will ad the scene to your build.
  • In the same dialog go to “Player Settings”
  • Look for the section “Resolution and Presentation”
  • Set Fullscreen mode to “Windowed”
  • Tick the box “Resizable Window” and close the Settings dialog
  • Click “Build” and choose a folder to build to. This will create a build for you. It should open the explorer with the location for you. If not, navigate to the folder you created.
  • Double click on “Inventory.exe” and do that three times
  • Choose “SERVER for the first one and click “START”
  • Choose “CLIENT” and “Player1Network” for the second one and click “START”
  • Choose “CLIENT” and “Player2Network” for the third one and click “START”

There you go, you have the Multiplayer Inventory running.

Persistence

The persistence can be configured on the Player1Network Prefab.

On the section persistence (red) you can set the following settings:

  • Persistance Interval: The interval the server will persist the inventory to the disk if it is dirty.
  • Auto Persistance: When ticked, the server will automatically persist the dirty inventory to the disk in the set interval. If not ticked, the server does not do any persistance.

The server stores the inventories to the Application Data path as a JSON File:

Unity – Scripting API: Application.persistentDataPath (unity3d.com)

Drop Loot

The persistence can be configured on the Player1Network Prefab.

On the section Loot (blue) you can set the following settings:

  • Drop Loot When Destroy: If this setting ist on, the inventory items will never be destroyed. They always will be spawned again. If it’s off the user is choosing through the menu if he wants to destroy an item or drop it.
  • Drop Randomly: When ticked, the items are dropped randomly in the drop radius defined. If it is not ticked, it will drop right on the player.
  • Drop Radius: The radius in which the item will drop when Drop Randomly is ticked.
  • Item Database: The item database from which the ItemObjects are taken as a reference
Categories: Inventory

0 Comments

Leave a Reply

Avatar placeholder