- Home /
Question by
teamheartcode · May 31 at 08:51 PM ·
networking
Netcode NetworkBehaviour IsServer/IsClient/IsHost
I've set up a new project and added the "com.unity.netcode.gameobjects" (v 1.0.0-pre.9).
Just adding a NetworkManager w/ corresponding script component and a GameObject "NetvarsManager" with a script attached:
using Unity.Netcode;
using UnityEngine;
public class NetvarsManager : NetworkBehaviour
{
void Start()
{
NetworkManager.Singleton.OnServerStarted += OnServerStarted;
NetworkManager.Singleton.OnClientConnectedCallback += OnClientConnected;
}
void OnServerStarted()
{
Debug.Log("OnServerStarted");
Debug.Log("IsServer: " + IsServer);
Debug.Log("IsClient: " + IsClient);
Debug.Log("IsHost: " + IsHost);
}
void OnClientConnected(ulong id)
{
Debug.Log($"Client connected (id {id})");
Debug.Log("IsServer: " + IsServer);
Debug.Log("IsClient: " + IsClient);
Debug.Log("IsHost: " + IsHost);
}
}
When starting the Player and Clicking "Start Host" in the properties of the running NetworkManager instance, the following gets logged:
I don't understand why the "OnClientConnected" callback states "false" for all three of IsServer/IsClient/IsHost. Shouldn't it be true, just like in the "OnServerStarted" callback?
log.png
(17.1 kB)
Comment
Your answer
Follow this Question
Related Questions
Unity networking tutorial? 6 Answers
Can I use not LAN IP in Network Manager? 0 Answers
Camera switches player in network game 1 Answer
Network spawn only specific client 0 Answers
Player Spawn point not changing 1 Answer