- Home /
The question is answered, right answer was accepted
Detect SinglePlayer mode in a Multiplayer game.
I have a multiplayer game, where 2 players can connect and play. I also want to add a Single-Player mode where the MaxConnections allowed is only 1 player. The problem is that the first player always joins by using "NetworkManager.singleton.StartHost();" and the second player joins by using NetworkManager.singleton.StartClient(); the problem is that when I set the MaxConnections to 1, it means max Client connections.. and doesn't count the Host (first player) as a connection. which mean that there still 2 players are able to connect into the single-player mode... Is there any way to set MaxConnections to 0? so no clients will be able to connect except the host? or just make the host Count as a connection. so it will not allow more connections from other clients? Thanks.
First of all, I know what the code does. I know what host/client/server means. Secondly, you don't need any more information to help me with the problem. the problem is that unity Doesn't count The Hosting player as a connection. I gave 2 possible solutions in my question that I think might work. but I didn't find how to make them work. You probably the one who doesn't know code if you didn't understand the question.
Good day @DarkT0mato
Sorry for that, I delete every day several posts of "kids" posting about its huge problem when they dont even know what they are doing. Normally, a post without code or references is because the user pretend that we give him a completed and tested script to do what they need..
Congratz for solving the issue! Good luck!
Ps: I close the post.
Answer by DarkT0mato · Jan 30, 2019 at 02:29 PM
I solved the problem by setting the max connections number to 5 when its single-player. and in the online scene i just Check if the MaxConnections is 5, (which mean its single player mode). then i just disconnect any connected client except the host.