- Home /
Synchronizing Item Crates
Hello,
I am working on a Networking project for school and am having some trouble synchronizing my item containers.
Items are selected from a random "pool" of items, and the containers all synchronize for all players initially. However, when taking an item out of the container, other players do not see what items have been taken.
Here are the add/remove item functions that are found on the crates
[ClientRpc]
public void RpcRemoveItem(int index)
{
print (index);
itemList.RemoveAt (index);
ui.RemoveAt (index);
}
[ClientRpc]
public void RpcAddItem(GameObject item)
{
itemList.Add(item);
currItems++;
for (int x = 0; x < ui.Count; x++) {
if (ui [x].name == "Empty Slot") {
ui [x].name = item.name;
ui [x].GetComponent<Image> ().sprite = item.GetComponent<itemStats> ().icon;
ui [x].GetComponentInChildren<Text> ().text = item.name;
ui [x].GetComponent<itemSelect> ().myItem = item;
break;
}
}
}
I know that you can't pass a GameObject through an Rpc function, but is there a way I can have the clients basically just copy the Item Containers itemList rather than have to call an add/remove function for each item?
Thanks
Your answer
Follow this Question
Related Questions
Unity hlapi networktransform rigidbody rotation and interpolation issue 1 Answer
SyncListStruct Unity Error 0 Answers
How to sync non-player objects with uNet? 1 Answer
UNET SyncVar on a NetworkInstanceId SyncList structure not updating across network 1 Answer
How do I find the player GameObject of the local player? 2 Answers