- Home /
Network messages (OnPlayerConnected, OnServerInitialized) never gets called
Hi I'm making a very simple multiplayer game for my client. However I'm stuck on some basics:
The network messages, supposedly derived from the MonoBehaviour, never gets called on my project.
public class CubePlayer : NetworkBehaviour {
void OnPlayerConnected(NetworkPlayer player) {
Debug.Log ("Player connected!");
}
}
The rest of the project is copied completely from this tutorial, but I've tried countless similar ones with no success. I can make the player connect to a host via the NetworkManager and create a player GameObject with local authority. I can even move the GameObject on one machine and sync it with the other, so I know for sure that the clients indeed do connect. But I never know when do they connect, because the handler functions (OnPlayerConnected) are never called. Do you guys have any idea what am I missing?
I think you need to read the scripting API for these pages again. I have found that certain messages only work in certain circumstances and are sometimes counter intuitive.