嗨,我正在使用 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);
}
我究竟做错了什么?网络似乎不会将每个头像预制件发送到所有实例。
谢谢。