Help please. How to PhotonNetwork.Instantiate with data?

Hello. I am currently to to instantiate a box when the player drops it (using “PhotonNetwork.Instantiate”). Now this box, when the player drops it is given data about that box, in the form of an Enum and then distributes the value to the box. But, when the other client picks it up, the box has no values.

When user client drops box:
[/IMG]
When other client drops it:
[/IMG]

code:
[RPC] void dropItem(Item item){

Vector3 playerPos = this.transform.position;
Vector3 playerDirection = this.transform.forward;
Quaternion playerRotation = this.transform.rotation;
float spawnDistance = 1;

Vector3 spawnPos = playerPos + playerDirection*spawnDistance;
string itemname = item.itemName;

GameObject itemAsGameObject = (GameObject)PhotonNetwork.Instantiate(“DroppedItem”, spawnPos, playerRotation, 0);

itemAsGameObject.GetComponent ().item = item;

}

As you can see the client that drops the box has the values. but they arent being passed over to the other clients on the network. how can i fix this?

You need to use the OnSerializeView method and send and receive packet information to be updated on the box. There is a networking sub forum. I suggest you post there. RPC allows you to call the method on all clients. Not transfer data

could you give me an example?

void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
       if (stream.isWriting)
       {   
         stream.SendNext(transform.position);
         stream.SendNext(transform.rotation);

       }
       else
       {
         correctPosition = (Vector3)stream.ReceiveNext();
         correctRotation = (Quaternion)stream.ReceiveNext();

       }
    }

This will update the position and rotation of an object over the network. The stream allows you to read/write data. SendNext sends packets out, and ReceiveNext reads packets in the order they are sent.

Iv been at it for a while now. I cant figure out how to reference the game object that is being created.

You use Network.Instantiate to create the object. You reference that object through a GameObject variable.

GameObject obj = Network.Instantiate() as GameObject

Your data pertaining to the instantiated object is now stored in obj.