您好我正在使用Photon服务器开发多人游戏。
问题在于我成功地实例化了我自己的角色控制器及其对撞机和其他玩家'同样。但是,当我运行多个项目实例时,我无法看到其他预制件,我也实例化了。我可以击中对撞机,但无法看到预制件。 每个玩家只能看到自己的化身,但他们可以互相击中对手。 代码是这样的:
void SpawnMyPlayer(){
GameObject cube = GameObject.Find("Spawn");
//this is my avatar prefab.
GameObject MyPlayerGO = (GameObject)PhotonNetwork.Instantiate ("newAvatar", cube.transform.position, cube.transform.rotation, 0);
//this is avatar's position
Vector3 prefabPos = new Vector3 (MyPlayerGO.transform.position.x, 0.8f, MyPlayerGO.transform.position.z);
MyNameDisplay = (GameObject)PhotonNetwork.Instantiate ("nameDisplay", cube.transform.position, cube.transform.rotation, 0);
//Avatar prefab which i can not see from other instance.
MyAvatar = (GameObject)PhotonNetwork.Instantiate (avatarPrefab, prefabPos, cube.transform.rotation, 0);
MyAvatar.transform.parent = MyPlayerGO.transform;
MyNameDisplay.transform.parent = MyPlayerGO.transform;
MyNameDisplay.guiText.text = avatarName;
standbyCamera.enabled = false;
((MonoBehaviour) MyPlayerGO.GetComponent ("FPSInputController")).enabled = true;
MyPlayerGO.transform.FindChild ("characterCamera").gameObject.SetActive (true);
}
我做错了什么?网络似乎并没有将每个头像预制件发送到所有实例。
感谢。