(PUN) - Synchronization?

Hello everyone.

I'm doing some tutorials, all simple for now. But, when creating the room and on the same pc log me in, no one can see changes in the scene.

Why?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class NetworkManager : Photon.MonoBehaviour {

    public GameObject gameManager;

    void Start()
    {

        gameManager = GameObject.Find("GameManager");

        PhotonNetwork.ConnectUsingSettings("1.0"); //Conectar ao Servidor Photon

    }

    //Interacao
    void OnGUI()
    {

        GUILayout.Label(PhotonNetwork.connectionStateDetailed.ToString()); //Retorna o estado da coneccao

        if (GUILayout.Button("Create Room"))
        {
            PhotonNetwork.CreateRoom("Teste");

            //gameManager.GetComponent<GameManager>().Player[0] = 1;

        }

        if (GUILayout.Button("Joint Room"))
        {
            PhotonNetwork.JoinRoom("Teste");

            /* Random
            //Tries to join any random game:
            PhotonNetwork.JoinRandomRoom();
            //Error callback: OnPhotonRandomJoinFailed
            */

            //gameManager.GetComponent<GameManager>().Player[1] = 2;
        }

    }

    void OnJoinedRoom()
    {
        //PhotonNetwork.LoadLevel("ScenePedro");

        PhotonNetwork.Instantiate("PlayerCamera",
            transform.position, transform.rotation, 0);
    }

}

Comments

  • Hi @Givago,

    [...] no one can see changes in the scene.


    What do you mean exactly? Is it about the PhotonNetwork.LoadLevel which is currently commented out or the Instantiation call?

    Additionally you have two different calls for joining the room from the second UI button. You should remove one of these calls, I actually don't know what happens if both of them gets called. In this case it is a good idea to just use PhotonNetwork.JoinRandomRoom().
  • I want you both to see changes on the screen, but no one sees changes.
  • The game object you are trying to instantiate in OnJoinedRoom, is it instantiated on both clients properly? Does the prefab has an attached PhotonView component observing e.g. the PhotonTransformView component in order to synchronize it's position across the network?
  • Givago
    Givago
    edited June 2017
    Yes, the two are creating correctly in the scene the game object. Yes, they both have PhotonView and PhotonTransformView the standard.

    http://imgur.com/a/HhPxy


    But in game, PhotonTransformView say:
    Editing is disabled in play mode so the two objects don't go out of sync
  • The PhotonView doesn't observe the PhotonTransformView, it currently observes the transform itself. Please adjust this and let me know, if this solves the issues you currently have.
  • The PhotonView doesn't observe the PhotonTransformView, it currently observes the transform itself. Please adjust this and let me know, if this solves the issues you currently have.

    This?

    https://uploaddeimagens.com.br/imagens/print-png--909

    No work =/
  • Givago
    Givago
    edited June 2017
    But, I can only see this Game Object:

    https://uploaddeimagens.com.br/imagens/sem_titulo-png--21859

    edit:
    I create the scenario with GameObject instance, do I need to use the PhotonNetwork.Instantiate?
  • If you want to have this object network synchronized, PhotonNetwork.Instantiate is the easy way to go. However you can use local Instantiation but have to inform other clients, so that they can instantiate the object as well. Last section of this guide describes the process about Manual Instantiation.

    No work =/


    Do you add the observed component in play-mode? If so please exit play-mode and set up the object in edit-mode. Besides that you have to check the option 'Synchronize Position' (same for rotation if needed), it is not enabled on the screenshot.