#Can not Instantiate before the client joined/created a room. State: JoiningUnityEngine.Debug:LogErr

1 messages · Page 1 of 1 (latest)

sleek sluice
#

need help to solve this problem

#

script with issue

#

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

public class RoomManager : MonoBehaviourPunCallbacks
{

public GameObject player;
[Space]
public Transform spawnPoint;

// Start is called before the first frame update
void Start()
{
    Debug.Log("Connecting...");
    PhotonNetwork.ConnectUsingSettings();
}

// Update is called once per frame
public override void OnConnectedToMaster()
{
    base.OnConnectedToMaster();
    Debug.Log("Connected To Server");
    PhotonNetwork.JoinLobby();
}

public override void OnJoinedLobby()
{
    base.OnJoinedLobby();
    PhotonNetwork.JoinOrCreateRoom("test", null, null);
    Debug.Log("You're Connected And In Room Now");

    GameObject _player = PhotonNetwork.Instantiate(player.name, spawnPoint.position, Quaternion.identity);
    _player.GetComponent<PlayerSetup>().IsLocalPlayer();
}

}

#

Making Fps Multiplayer using photon PUN2

wintry thunder
#

the error is pretty explicit on whats wrong, where do you think the problem is?

frozen ironBOT
#

Use codeblocks to send code in a message!

To make a codeblock, surround your code with ```
To use C# syntax highlighting add cs after the three back ticks.

For example:
```cs
Console.WriteLine("Hello World");
```

Produces:

Console.WriteLine("Hello World");

To send lengthy code, paste it into https://paste.myst.rs/ and send the link of the paste into chat.

#

Pictures of exceptions are not helpful

Pasting a picture of an error or an exception is not helpful. It is not required to prove that the error happened – you are trusted when you state this fact within the question. It is the details omitted by these images that is the problem, as these images only contain part of the information.
Source: https://idownvotedbecau.se/imageofanexception

Please copy and paste the error as text so that we can further understand all of the relevant information, and point out the exact line that is throwing the error, as this saves the time of those who are helping you!

sleek sluice
#

at here

#

@sleek sluice

wintry thunder
#

you are on the right track

#

what is the error telling you?

sleek sluice
# wintry thunder you are on the right track

Can not Instantiate before the client joined/created a room. State: Joining
UnityEngine.Debug:LogError (object)
Photon.Pun.PhotonNetwork:Instantiate (string,UnityEngine.Vector3,UnityEngine.Quaternion,byte,object[]) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetwork.cs:2477)
RoomManager:OnJoinedLobby () (at Assets/RoomManager.cs:34)
Photon.Realtime.LobbyCallbacksContainer:OnJoinedLobby () (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:4431)
Photon.Realtime.LoadBalancingClient:OnOperationResponse (ExitGames.Client.Photon.OperationResponse) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:2920)
ExitGames.Client.Photon.PeerBase:DeserializeMessageAndCallback (ExitGames.Client.Photon.StreamBuffer) (at D:/Dev/Work/photon-dotnet-sdk/PhotonDotNet/PeerBase.cs:877)
ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands () (at D:/Dev/Work/photon-dotnet-sdk/PhotonDotNet

#

if i can't reply you in time plz dont be upset because i'am going for paper i will be online on 1pm