Answer the question
In order to leave comments, you need to log in
PhotonNetwork.Instantiate doesn't work. How to fix?
There is a line of code:
PhotonNetwork.Instantiate("Test", new Vector3(0,0,0), Quaternion.identity, 0);
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Realtime;
using ExitGames.Client.Photon;
using UnityEngine.UI;
using System.Threading.Tasks;
public class map : Photon.PunBehaviour
{
public Text text;
public int radius = 15;
public Generator generator;
public GameObject player;
// Start is called before the first frame update
void Start()
{
Destroy(GameObject.Find("Player"));
PhotonNetwork.ConnectUsingSettings("1.0");
}
private void OnConnectedToMaster()
{
PhotonNetwork.JoinLobby();
}
public override void OnJoinedLobby()
{
PhotonNetwork.JoinRandomRoom();
}
public override void OnJoinedRoom()
{
if(PhotonNetwork.room.PlayerCount < 2)
{
text.text = "wait for players";
}
else
{
PhotonNetwork.Destroy(text.gameObject);
}
player = PhotonNetwork.Instantiate("Player", Vector3.zero, Quaternion.identity, 0);
player.gameObject.tag = "Player";
print(player.gameObject.tag);
PhotonNetwork.Instantiate("Test", new Vector3(0,0,0), Quaternion.identity, 0);
}
public void OnEvent(EventData photonEvent)
{
if (photonEvent.Code == 1)
{
}
}
void OnPhotonInstantiate(PhotonMessageInfo info)
{
print("d");
}
void OnPhotonRandomJoinFailed()
{
PhotonNetwork.CreateRoom("play");
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question