Unity, Oculus and Photon PUN2.... Configuration Problems

Options
I am trying to develop a multiplayer game with Photon and I have a problem that I feel unable to solve.
I'm using Unity 2019.1.7f1 and Photon PUN2.

The first player creates a room with a custom name and enters the room.
And the second player can see the updated room list and join the room
the first player (master) sees the second player move but the second player sees the avatar of the first player at the point (0,0,0)... So only the room owner is seeing the movement of the other players.
I don't know why this could be happening, and I'm going crazy.

Help Please! :smile:

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

using Photon.Pun;
using Photon.Realtime;

public class TestConnect : MonoBehaviourPunCallbacks, IMatchmakingCallbacks
{

public player_info player_Info;

void Start()
          {
     
            PhotonNetwork.SendRate = 20;
            PhotonNetwork.SerializationRate = 15;
            playerNickname = player_Info.playerID + " / " + player_Info.playerName;
            PhotonNetwork.NickName = playerNickname;
            PhotonNetwork.GameVersion = MasterManager.GameSettings.GameVersion;
            
            Debug.Log(PhotonNetwork.NickName.ToString());

            PhotonNetwork.ConnectUsingSettings();

            if(PhotonNetwork.InRoom == false)
            {
            Setlocalplayer();
            } 
    }

  public override void OnConnectedToMaster()
  {
         print("Connected to server");
         if(!PhotonNetwork.InLobby)
         PhotonNetwork.JoinLobby();
  }

  public void Onclick_createRoom()
  {
        if(!PhotonNetwork.IsConnected)
        return;

        RoomOptions options = new RoomOptions();  
        options.MaxPlayers = 4;
        PhotonNetwork.JoinOrCreateRoom(_roomName.text ,options, TypedLobby.Default);
       
  }

 public void OnClick_JoinRoom(string room_name)
 {
     PhotonNetwork.JoinRoom(room_name); 
 }


  public override void OnCreatedRoom()
  { 
      print("Created room Succesfully"); 
  }



  public override void OnJoinedRoom()
  {   
       Debug.Log("instantiating a new player");
       PhotonNetwork.Instantiate("01_networkedplayer", Vector3.zero, Quaternion.identity,0);
  }
}


And this is my Avatar Instantiated Code on the Resources folder whit the PhotonView (Fixed & Delta Compressed)

using UnityEngine;
using System.Collections;
using Photon.Pun;
using Photon.Realtime;
using OVR;
using OVRTouchSample;



// For use with Photon 
public class NetworkedPlayerHead : MonoBehaviour, IPunObservable
{
    public GameObject avatar;
    public Transform playerGlobal;
    public Transform playerLocal;

    public GameObject LeftHandNet;
    public Transform L_handLocal;
    public Animator L_handanimator;

    public GameObject RightHandNet;
    public Transform R_handLocal;
    public Animator R_handAnimator;


    private PhotonView _PhotonView;


    void Start()
    {
         _PhotonView = GetComponent<PhotonView>();
       

        if (_PhotonView.IsMine)
        {
            Debug.Log("Player is mine");
            
            //head

            playerGlobal = GameObject.Find("OVRPlayerController").transform;
            playerLocal = playerGlobal.Find("OVRCameraRig/TrackingSpace/CenterEyeAnchor");

            this.transform.localPosition = Vector3.zero;
            this.transform.SetParent(playerLocal);
            this.transform.localPosition = Vector3.zero;
            
            //Left hand
            
            L_handLocal = GameObject.Find("CustomHandLeft").transform;

            L_handanimator = LeftHandNet.GetComponent<Animator>();
            GameObject.Find("CustomHandLeft").GetComponent<Hand>().m_animator = L_handanimator;
            
            LeftHandNet.transform.SetParent(L_handLocal);
            LeftHandNet.transform.localPosition = Vector3.zero;
            LeftHandNet.transform.localRotation = Quaternion.Euler(0,0,0);

            //Right hand
            
            R_handLocal = GameObject.Find("CustomHandRight").transform;

            R_handAnimator = RightHandNet.GetComponent<Animator>();
            GameObject.Find("CustomHandRight").GetComponent<Hand>().m_animator = R_handAnimator;
            
 
            RightHandNet.transform.SetParent(R_handLocal);
            RightHandNet.transform.localPosition = Vector3.zero;
            RightHandNet.transform.localRotation = Quaternion.Euler(0,0,0);
    
        }

    }
	
  void IPunObservable.OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        if (stream.IsWriting)
        {
            stream.SendNext(playerLocal.position);
            stream.SendNext(playerLocal.rotation);
            stream.SendNext(L_handLocal.position);
            stream.SendNext(L_handLocal.rotation);
            stream.SendNext(R_handLocal.position);
            stream.SendNext(R_handLocal.rotation);
        }
        else
        {

            avatar.transform.position = (Vector3)stream.ReceiveNext();
            avatar.transform.rotation = (Quaternion)stream.ReceiveNext();
            LeftHandNet.transform.position = (Vector3)stream.ReceiveNext();
            LeftHandNet.transform.rotation = (Quaternion)stream.ReceiveNext();
            RightHandNet.transform.position = (Vector3)stream.ReceiveNext();
            RightHandNet.transform.rotation = (Quaternion)stream.ReceiveNext();

        }
    }
}

Thank you.

Comments

  • JOS
    JOS
    edited February 2020
    Options
    Thanks , don't worry . I've found the solution. Changing in NetworkedPlayerHead void Start() for Enabled(). Sorry for the inconvenience XD. I'll keep working .... I've been looking for the solution for a week... XD.... today I ask and today... I found the solution. :D
  • Hamdan
    Options
    JOS wrote: »
    Thanks , don't worry . I've found the solution. Changing in NetworkedPlayerHead void Start() for Enabled(). Sorry for the inconvenience XD. I'll keep working .... I've been looking for the solution for a week... XD.... today I ask and today... I found the solution. :D

    Hey Jos,

    I'm kind of stuck where you were before, looking at your code, I am wondering on the approach that you have applied.

    1. You instantiated an OVRPlayerController from the Resources Folder
    2. You created an Empty GameObject (I'm naming this as GO) and attached the NetworkedPlayerHead script, on connected, you instantiated GO, and GO finds and OVRPlayerController that is already inside the scene.

    Which of these two approach that you went with?
    What does the LeftHandNet and RightHandNet refers to?
    Also what do you mean changing from void Start for Enabled()? Do you mean override void OnEnable()?