1

in photon the first person to join can see both players but second to join cant see the first. anyone know why? connect to server script

using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
using UnityEngine.SceneManagement;
public class Connecttoserver : MonoBehaviourPunCallbacks
{
    private void Start()
    {
        PhotonNetwork.ConnectUsingSettings();
       
    }
    public override void OnConnectedToMaster()
    {
        PhotonNetwork.JoinLobby();
    }
    public override void OnJoinedLobby()
    {
        PhotonNetwork.JoinRoom("Server");
    }
    public override void OnJoinedRoom()
    {
        
        SceneManager.LoadScene("Game");
    }
    public override void OnJoinRoomFailed(short returnCode, string message)
    {
        Debug.Log(message);
        PhotonNetwork.CreateRoom("Server");
    }
    
}

spawn players script

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;

public class spawnplayers : MonoBehaviour
{
    public GameObject playerprefab;
    public float minx, maxx, minz, maxz;

    private void Start()
    {
        Vector3 randompos = new Vector3(Random.Range(minx,maxx),1,Random.Range(minz,maxz));
        GameObject myPlayerGO = (GameObject)PhotonNetwork.Instantiate(playerprefab.name, randompos, Quaternion.identity);
        myPlayerGO.GetComponent<playermovement>().enabled = true;
        myPlayerGO.GetComponentInChildren<CameraLook>().enabled = true;
        myPlayerGO.GetComponentInChildren<Camera>().enabled = true;
    }
}

Screen 1

Screen 2

Anybody know a solution?? I have been trying to solve this for days but to no success

what ive tried

  1. adding heaps of debug logs
  2. adding photonview and transform
  3. crying myself to sleep

2 Answers2

0
  • Make sure both clients are connected to the same server (Region if Photon Cloud) and to the same Virtual Application (if Photon Cloud). You could make use of SupportLogger. Check Matchmaking Checklist.
  • Use PhotonNetwork.LoadLevel instead of SceneManager.LaodLevel.
  • Also, you could make use of JoinOrCreateRoom method as a shortcut instead of trying to join then creating one.
  • I would start by finishing PUN Basics Tutorial first or following one of YouTube tutorials about PUN.
JohnTube
  • 1,782
  • 27
  • 46
0

When players join map, use PhotonNetwork.LoadLevel("SceneName") instead of SceneManager.LoadScene("SceneName").

Syscall
  • 19,327
  • 10
  • 37
  • 52
Maja
  • 1