if(identity.isOwned){
// Set Instance too equal this player
// Will allow for script to gain access to the correct player for the client
}
[Command]
public void CmdDropItems(int amount, ItemData item)
{
for (int i = 0; i < amount; i++)
{
GameObject itemDrop = Instantiate(ItemDropPrefab, Camera.main.ScreenToWorldPoint(Input.mousePosition), Quaternion.identity);
NetworkServer.Spawn(itemDrop);
itemDrop.GetComponent<ItemDrop>().item = item;
}
}
CmdDropItems
is a command that run on the server.NetworkServer.Spawn
to ensure item drops are instantiated across the network.These changes ensure that inventory actions are synchronized across all clients in a multiplayer environment.