OnStartClient() is not being called on the host player object.

Hi everyone.

I’m building a volleyball game using UNet and I’m having trouble with the teams initialization. When I start the host via the NetworkManagerHUD the program doesen’t seem to be calling the OnStartClient() hook. If I start a dedicated server and two other clients, the functions are callled correcty instead. I’ve read unity’s documentation thousand times but I can’t seem to find a solution, since it says that the host also runs as a client.

Make sure that you’re using public override void OnClientStart() for the function definition.

If you don’t, it won’t run your derived method but will instead act as if you are using public new void OnClientStart() and will call the parent OnClientStart() but not yours.

Bit of a hack, and I’m not entirely sure it works, but when I ran into the problem, I stuck a bit of code in that called OnStartClient() within OnStartHost(). From the documentation, it seems like that shouldn’t be necessary, but oh well!

I literally mean

function OnStartHost() {
     OnStartClient();
}

If you want to call something on server side while client connecting use OnClientConnect()