Inventory Singleton Issue

Options
Hello,
I am new using Photon PUN 2 and i am facing to an issue.
i am trying to implemente Inventory system
My inventoryManager is singleton evething work well but when i drop an item on the ground if i pickup it with an other player this item is always put back in the inventory of the player who throw this item.

i transfer ownership of the Object to the player who collier with but same thing, so maybe it's because my inventory is singleton but i don't understand how the gameobject can be placed back in the creator inventory because this inventory is not networked so there is 1 inventory Singleton on each client and each client have à knowledge about inventory singleton of other player

If someone can help me pls :)

Comments

  • mjoye
    mjoye
    edited December 2018
    Options
    Hello,

    Why do you need the Inventory Manger(or inventory) as singleton? The inventory system is tied the player and only that player(if you allowing for local co-op too). It may help to see your code since without it is hard to tell what is going. It does not matter which client has ownership of the GameObject item, that just means that client is telling the server what is happening to that GameObject. Somehow in your code you are placing the item into the other person inventory on the client side. I would recommend that only one client knows about that players inventory and not about other players inventory, and if they need to know something about another client status, they should ask it.



    My system tracks items in all user inventory and out on the field both locally and up to the server.

    My inventory system works like this:

    Player can drop items:
    Player A drops item-> item is removed from local inventory->send the message that player drop item from inventory(this way it removes from the inventory)-> spawns a new GameObject Item with a new ObjectId-> tell server about this new GameObject and what item is it and it's id;

    player pick up item
    Note: there is a small delay between when the player press the button to pick up an item, and when the item is picked up just in case for lag.
    Player B to pick up item-> tells server about GameObject begin destroy to report to other clients-> add item to local inventory-> tells server for the new state of the players inventory