0

Hi i'm developing a multiplayer game with Photon server.

The problem is i'm sucessfully instantiating my own character controller and its collider and the other players' as well. But when i run more than one instance of the project i cant see the other prefabs which i also instantiated. I can hit the collider but cant see the prefab. Every player can only see his own avatar but they can hit their colliders one another. Code is like this:

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);
  }

What am i doing wrong? Network doesnt seem to send every avatar prefab to all instances.

Thanks.

Zzap
  • 174
  • 2
  • 3
  • 14
  • Based on the wording I'm wondering whether you are aware that each client needs to instantiate the objects? The server doesn't do (or "send") this automatically. There's got to be a notification of some kind that clients receive from the server in order to create additional player instances. – CodeSmile Jul 15 '14 at 09:36
  • Since i do PhotonNetwork.Instantiate(blabla) doesnt all clients instantiate the object ? – Zzap Jul 15 '14 at 11:14
  • I'm not familiar with Photon, perhaps this transmits to clients and does the same thing but instantiating the object may not be enough, or transmission may not be done reliably (UDP vs TCP). – CodeSmile Jul 15 '14 at 12:29

0 Answers0