- Home /
Instantiating player when creating a new room in photon not working.
Context: I am having a problem with the quick match system that I am trying to implement into my multiplayer game. I can get players to join a room, I also have it so that once a room has the maximum amount of players in it, the person trying to join that room will create and new room.
My problem is that when the player trying to join the room with the max amount of players in it makes a new room, the network player prefab that I made will not instantiate. I am very confused because the scene is loaded and the players local controller is put into the scene so you can move around, but you cant interact with any of the objects in the scene because they have photon view components on them. And yes I do have a photon view on my network player prefab.
Any tips would greatly help. I am really just at a loss here and have tried everything I can think of so far.
Here is the code that spawns my network player:
using System.Collections; using System.Collections.Generic; using UnityEngine; using Photon.Pun; using Photon.Realtime;
public class NetworkPlayerSpawner : MonoBehaviourPunCallbacks { private GameObject spawnedPlayerPrefab;
public override void OnJoinedRoom()
{
base.OnJoinedRoom();
spawnedPlayerPrefab = PhotonNetwork.Instantiate("Network Player", transform.position, transform.rotation);
}
public override void OnLeftRoom()
{
base.OnLeftRoom();
PhotonNetwork.Destroy(spawnedPlayerPrefab);
}
}
Your answer
Follow this Question
Related Questions
Light.color Sync ? 1 Answer
Cannot Instantiate Player on PhotonNetwork 0 Answers
Photon connections problems caused by a script? 2 Answers
Synchronize damage dealing and block in melee combat multiplayer game 2 Answers
how to make game object animation without animator visible to all players in photon pun? 2 Answers