Unity adding the host as a player when starting the server

1.4k Views Asked by At

Currently im trying to make a lobby system for my game, the lobby system seems to have quite a few issues but im slowly working my way through them. I cannot however, find out a way to make the host automatically get added as a player in the game, when he starts a server. There will never be a situation where the host will only act as the server, so i need him to automatically get added to the game.

I have tried a bunch of different things with ClientScene.AddPlayer() But i cannot make this work.

Further, i cannot find any documentation on what functions the different buttons on the standard unity network lobby hud actually do, so i have a hard time replicating the behaviour.

Anyone has any good sources /ideas on the issue?

2

There are 2 best solutions below

2
On

There is a method in the given NetworkManager called StartHost(). Try this for starting the server.

See the Scripting API for NetworkManager.StartHost() and all the methods from the NetworkManager

0
On

You have to write a custom UI and network manager to eliminate the Start Server GUI option which is by default provide by the Unity Networking GUI component. You can view this simple tutorial (UI & Custom Net Manager) to understand it.