- Home /
On NetworkLobbyManager override, base.OnLobbyServerCreate[Lobby/Game]Player() return null. Is that normal ?
Hi,
I made a sample project illustrating my question.
This projet consists of the minimal network game managed by an overrided LobbyNetworkManager.
Here is the source code of my LobbyNetworkManager override :
using UnityEngine;
using UnityEngine.Networking;
using System.Collections;
public class TEST_NetworkLobbyManager : NetworkLobbyManager {
public override GameObject OnLobbyServerCreateGamePlayer(NetworkConnection conn, short playerControllerId)
{
GameObject gamePlayer = base.OnLobbyServerCreateGamePlayer(conn, playerControllerId);
if (gamePlayer == null)
{
Debug.Log("The gamePlayer instancied by base.OnLobbyServerCreateGamePlayer(conn, playerControllerId); is null");
}
return gamePlayer;
}
public override GameObject OnLobbyServerCreateLobbyPlayer(NetworkConnection conn, short playerControllerId)
{
GameObject lobbyPlayer = base.OnLobbyServerCreateLobbyPlayer(conn, playerControllerId);
if (lobbyPlayer == null)
{
Debug.Log("The lobbyPlayer instancied by base.OnLobbyServerCreateLobbyPlayer(conn, playerControllerId); is null");
}
return lobbyPlayer;
}
public override bool OnLobbyServerSceneLoadedForPlayer(GameObject lobbyPlayer, GameObject gamePlayer)
{
return true;
}
}
When I start the host, my first custom message is displayed : "The lobbyPlayer instancied by base.OnLobbyServerCreateLobbyPlayer(conn, playerControllerId); is null"
When I set to ready, this one is displayed : "The gamePlayer instancied by base.OnLobbyServerCreateGamePlayer(conn, playerControllerId); is null" Plus, the lobbyPlayer is still present on the scene (according to the doc, I expected it to be replaced by the gamePlayer).
Are those things normal or not ?
Here is an archive of the sample project.
That's normal. The method (OnLobbyServerCreateGamePlayer) is just a empty virtual method. The network engine calls it in the right place, if it returns null, the engine assumes that you have not overriden it, and therefore need no customization at this place.
Your answer
Follow this Question
Related Questions
Prevent NetworkLobbyManager from changing scenes. 2 Answers
OnStart ___ vs OnLobbyStart ___ methods from NetworkManager and NetworkLobbyManager 1 Answer
Player Prefab on Lobby Managers? 5 Answers
Cannot Convert type UnityEngine.Networking.PlayerController to PlayerController 1 Answer
UNET - Why is my NetworkInstanceID equal on both clients when receiving ClientRpc? 1 Answer