- Home /
Question by
alexlam127 · Aug 15, 2013 at 02:31 AM ·
networkingmultiplayer
RPC instantiate owner problem
i have a scene object(already in heirachy) with a spawn script(below) and networkview component. To create a camera and an object for server and client. both camera and object is a prefab with networkview component attached.
so i have test it in game with networkview.isMine and found that both camera is owned by server but one object is owned by server,one object is owned by client.
but both camera and object is basically using the same code ...dont know what went wrong... any advice is appreciated.
void OnServerInitialized() {
NetworkViewID viewID = Network.AllocateViewID();
networkView.RPC("SpawnObject", RPCMode.AllBuffered,viewID,transform.position);
}
void OnConnectedToServer(){
NetworkViewID viewID = Network.AllocateViewID();
networkView.RPC("SpawnObject", RPCMode.AllBuffered,viewID,transform.position);
}
[RPC]
void SpawnObject(NetworkViewID viewID, Vector3 location) {
//create camera
GameObject cam = (GameObject)Instantiate(mycamera, location, Quaternion.identity);
NetworkView iView;
iView = cam.transform.GetComponent<NetworkView>();
iView.viewID = viewID;
//create object
orc1 = (GameObject)Instantiate(orc, location, Quaternion.identity);
NetworkView mView;
mView = orc1.transform.GetComponent<NetworkView>();
mView.viewID = viewID;
}
Comment
Your answer
Follow this Question
Related Questions
Unity networking tutorial? 6 Answers
hovering usernames with photon 1 Answer
photon networking and unity networking 1 Answer
What can i use besides an event current 1 Answer
A node in a childnode? 1 Answer