The Photon Forum
is Closed Permanently.

After many dedicated years of service, we have made the decision to retire our Forum and switch to read-only: we´ve saved the best to last! Your search result can be found below. Plus, we offer support via these channels:

Try Our
Documentation

Please check if you can find an answer in our extensive documentation on PUN.

Join Us
on Discord

Meet and talk to our staff and the entire Photon-Community via Discord.

Read More on
Stack Overflow

Find more information on Stack Overflow (for Circle members only).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

Can not Instantiate before the client joined/created a room. State: PeerCreated

Ad1yar
2022-10-13 11:32:20

Hi all! I got an error when creating a shooter, yes, I'm between junior and middle (the name is the error) here is the code:

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

using Photon.Pun;

public class SpawnManager : MonoBehaviourPunCallbacks

{

public GameObject[] redSpawn;

public GameObject[] blueSpawn;

public GameObject Player;

void Update()

{

Awake();

}

private void Awake()

{

if (Choice.redChoice == true)

{

Vector3 randomRedPosition = redSpawn[Random.Range(0, redSpawn.Length)].transform.localPosition;

PhotonNetwork.Instantiate(Player.name, randomRedPosition, Quaternion.identity);

}

if (Choice.blueChoice == true)

{

Vector3 randomBluePosition = blueSpawn[Random.Range(0, blueSpawn.Length)].transform.localPosition;

PhotonNetwork.Instantiate(Player.name, randomBluePosition, Quaternion.identity);

}

}

}

The problem is here: PhotonNetwork.Instantiate(Player.name, randomRedPosition, Quaternion.identity); and PhotonNetwork.Instantiate(Player.name, randomBluePosition, Quaternion.identity);

Help please in the forums did not find now I sit and think

Comments

Tobias
2022-10-17 14:21:15

It sounds a lot as if you guesstimate your way into using PUN. This is likely to fail and cost you time. Even more if you have to wait.

The error basically tells you: Before you network instantiate objects, go online, find a match.

Do the PUN Basics Tutorial and code it.

Back to top