Players won't spawn with Photon Unity Network
Hello recently I have been having this issue and sorry is i miss any information out, I would not cast myself as an expert on this stuff. So I have been using Phonton Unity Networking however my player won't spawn. I have not recived any errors in the console but I did get a message that said "Udp PhontonNetwork.connected: False UnityEngine.Debug:Log(Object). I have placed my prefab in a resources folder and I have, of course, done all the basic steps. If i could get any help that would be much appreciated. Thanks.
My Code:
using UnityEngine; using System.Collections;
public class NetworkManager : MonoBehaviour { const string VERSION = "v0.0.1"; public string roomName = "VVR"; public string playerPrefabName = "FPSController"; public Transform spawnPoint;
void Start()
{
PhotonNetwork.ConnectUsingSettings(VERSION);
}
void OnjoinedLobby()
{
RoomOptions roomOptions = new RoomOptions() { isVisible = false, maxPlayers = 4 };
PhotonNetwork.JoinOrCreateRoom(roomName, roomOptions, TypedLobby.Default);
}
void OnJoinedRoom()
{
PhotonNetwork.Instantiate(playerPrefabName,
spawnPoint.position,
spawnPoint.rotation,
0);
}
}
Tutorial I am watching : https://www.youtube.com/watch?v=v9m48nhfgvI
Answer by ChristianSimon · Sep 08, 2016 at 10:58 AM
Hi Harry_1545,
you are never joining any lobby or room because the signature of your callback is wrong. It has to be OnJoinedLobby()
with an uppercase 'J'. Additionally make sure that you are automatically join lobbies at all. You can do this by checking the 'Auto-Join Lobby' option in the PhotonServerSettings file or by adding PhotonNetwork.autoJoinLobby = true;
at the beginning of your start function.