BIG thank you to stefan429, he is right, well the things he mentioned in his comment: if youre having issues, MAKE SURE: 1. your networkManager has the roomPlayer prefab assigned at the bottom 2. youre using path instead of name for checking the active scene in both OnServerConnect AND OnServerAddPlayer in NetworkManagerLobby, i.e. SceneManager.GetActiveScene().path so for number 2, in detail, in the youtube tutorial, it shows: if(SceneManager.GetActiveScene().name != menuScene) { conn.Disconnect(); return; } BUT you need to change it to: if(SceneManager.GetActiveScene().path != menuScene) { conn.Disconnect(); return; } that fixed the problem... ONE LAST thing i am trying to figure out, is my lobby, the Roomplayer prefabs never show up on the Left side that shows the tree and the objects... not sure why :(
@@meddjihed9108 If you have the bug where Roomplayer doesn't get instanciated: NetworkManagerLobby.menuScene doesn't get converted to the rigth string, so if (SceneManager.GetActiveScene().name == menuScene) won't be true. Fix this by making [SerializeField] string menuScene; And type in the scene name in the inspector instead of dragging in the scene. Used Unity 2020.1.6f1 Credit:- @Julian Röckl
What I reccomend for ur clips to use diffrent workflow or order when u record this tutorials, first show us UI then code. This way u keeping trowing new files and scipts, but when u create it I do not know why do u need that new script, so script doesnt make sense until I see UI and then I need to scroll through scipts again to understand why I wrote some methods. In this alternative I will understand it first time, while I am writting code. But thank u for ur work anyway, keep going :D
I second this because our UI is usually different from your UI and it's better to know in advance what parts of your code we should ignore and it's also really confusing when you mention all these different scripts but we don't even have a visual representation yet of why we are doing it this way, this does cause us to have to jump back and forth a lot. Thanks for these excellent tutorials, hope you don't mind our feedback.
I get a little lost, trying to figure out what code we are supposed to create, and what code comes with Mirror. I definitely love it when you show us your screen while you type it out. Either way it is a great tutorial, and definitely helps us create a network lobby without any experience. Thank you!
If you have the bug where Roomplayer doesn't get instanciated: NetworkManagerLobby.menuScene doesn't get converted to the rigth string, so if (SceneManager.GetActiveScene().name == menuScene) won't be true. Fix this by making [SerializeField] string menuScene; And type in the scene name in the inspector instead of dragging in the scene. Used Unity 2020.1.6f1
Its a really good tutorial but you should explain more thoroughly or go slower , i was stuck trying to figure out why my intelisense would not recognize the event action bit and in the end i realized is because i was missing using system. But overall a really great tutorial man.
Make sure you check out the project in github too - that's how I fixed all my missed imports that were throwing errors :) my ide is awful at picking up intellisense haha
public void SetPlayerName(string name) { continueButton.interactable = !string.IsNullOrEmpty(name); } this line of code is broken for no reason. But it got fixed with public void SetPlayerName(string name) { continueButton.interactable = nameInputField.text.Length >= 4; } I do not know why it got fixed
Would love some help - My unity player launches the lobby fine when I host, when I join the localhost on the build version it joins but all it says is "Lobby Tutorial" it doesn't create another player. I'm not getting any errors. Thoughts?
Amazing video, clear and concise explanations at every step. Really helped break down the process of setting up a lobby, which I've been too daunted by before now to get any further than the first couple of files on my own! Thank you so much :)))))
the "confirm" button for the name UI needs to be "interactable" in order for it to be clickable. It was unchecked by default, and it wouldn't allow the UI to move onto the next page.
Guys help me, my "Empty" object is not spawning, and neither is the "NetworkGamePlayerLobby" prefab. It's all set right in NetworkManager. if anyone knows please help me.
It would appear there is no function called OnClientConnect() in the class NetworkBehaviour. Has it been removed in some update since this video, or has it changed name?
I'm following your wonderful series (which you said it is not a series ahahah), anyways, is there the possibility to create multiple lobbies contemporarily to which the users can connect by a name or an ID? I mean private lobbies for groups of people
After following this video and the next one in the playlist, I'm having trouble connecting a client to the host. I've ensure the transport IP is localhost, but still no results. If it helps, the logs show the host accepting the connection and then the client immediately disconnects. On the flip side when running a client in editor and attempting to join the lobby by specifying "localhost", the only message that appears is a timeout message. Any ideas what could be going on here?
I actually solved the issue on my own after taking a break and coming back to this. The menuScene variable doesn't store the correct value. I simply hard-coded it to the value of "Scene_Lobby" to get it to work. Hope this helps anyone who might be having this problem!
thanks for the great tut! I'm having a really weird issue, where i am trying to override methods from the NetworkManager but it says that no suitable method can be found. I swear I'm inheriting from the base class correctly
Okay, I solved the problem for anyone who might be interested, the problem was that i had another package installed (called rasa, a chatbot framework) which also had a class called NetworkManager which I was inheriting from. Oops
Guys I found the problem, since I had the same ^^ using [Scene] [SerializeField] private string menuScene; results the string being "your current path to the assets folder + path to your scene + scene name". Now in the OnServerConnect method we check if the client tries to join an ongoing game, where we check if(SceneManager.GetActiveScene().name != menuScene). That results in checking the hole path string against just the scene name. So the Client gets disconnected immediately and the roomPlayer doesnt gets instantiated. If you fix the string menuScene, to only contain the actual scene name, it will work properly ! :D
@@Frenuellcrackser33 i now get a error saying the object i want to instantiate is null, i've bene looking for a while but cant find a answer, would you be able to point me in the right direction? also thanks for the previous fix :) the error is with the instantiation of roomplayerprefab in Networkmanager
@@asdfbasdfabwe make sure that rhe RoomPlayer Prefab is referenced in the NetworkManager(Lobby) script in your scene. For the Player Prefab aswell as the Room Player Prefab.
I'm getting a 'no suitable method found to override' error for both the OnServerAddPlayer method and the OnServerConnect method. Any solution? thanks in advance :)
me too, I'm also having that issue: [EDIT] Found out why and how to fix it: change "public override void OnServerDisconnect(NetworkConnection conn)" to "public override void OnServerConnect(NetworkConnectionToClient conn)"
This is a lovely tutorial! It really helped me get started in building a LAN lobby, and saved me hours of time and headache ! However.. I was wondering if it was possible to connect using a room name instead? Something like substituting the IP address with the room name when the lobby is created I am having trouble doing that and the system can only recognise the network address being changed locally, while the network address of the host is something like 'my room', in the client, it registers as 'localhost' still.. Any help would be much appreciated, I've spent so much time trying to figure this out and am unable to do much about it >
Sure, but you need a backend solution for that. It should store map with ip_address => room_name and when user sends room name to server, it should resolve it with ip address.
@@littledumpling5614 Hello! I used another method, so if you're looking for how to do something similar to what I wanted to using the localhost method, I'm afraid I can't help you. If you'd like to know the other method however, I'll explain a bit about it! So rather than have my players input the IP or localhost, I decided to use Network Discovery instead. Basically, NetworkDiscovery, upon starting a local host, will advertise it as a server, so all clients will be able to see it when they look for a server, and will then be able to join it! It's also possible to display a list of servers active, I didn't do it for my project because it isn't needed. The built-in script does make that work though, so I recommend experimenting with it. Here's what I used to get started: mirror-networking.com/docs/Components/NetworkDiscovery.html?q=network%20discovery All the best!
PlayerPrefs is volatile right. It's only accessible till the app cache is uncleared. When the player clears the cache then the data saved is gone right?
Thanks for the tutorial! One question though. In the "OnServerAddPlayer" function, why did you instantiate the roomplayerprefab instead of a player prefab. Is there a reason for this?
@@A_Reaper23 The reason is, I guess, this script is only making players join the Lobby Room and not the Game itself. Things like PV, Mana and else that we could need in game won't be usefull in lobby so we can use different prefabs. (I hope you did find your answer before but just in case you didn't ... ;) )
Whenever I join lobby on my remote build after hosting a lobby it connects, creates player, than instantly disconnects. It goes onEnable, joinLobby, onStartClient, onClientConnect, handleClientConnected, onDisable, onClientDisconnect. Did anyone have a similar issue?
Having the same issue, has anybody found a solution to this problem? The roomplayer gets instantiated on host but as when I go to join on a different computer the OnServerAddPlayer() method is not even called, I then am promptly disconnected.
@@Imdad6629 I have solved the problem with me hope it can help you and also the others if someone has the same problem. so go to the game object "NetworkManager" where you also have the NetworkManagerLobby script on it, with me has there always automatically created the Kcp transport that's wrong delet it. search for "Telepathy Transport" at component and link it in the inspector in the NetworkManagerLobby script.(my english is not so good i hope it helps u out :)
Hey Dapper Dino ^^ I really appreciate these tutorials! I learn a lot from you and it's great. I've looked at the Mirror documentation because I really want to be able to name my lobby, your tutorial showed how to connect directly via. IP address, but if I want a server list, surely I would also want names for servers. Could you perhaps show how to do that? I've looked around the internet for days and can't find anything. Thank you in advance :) To clarify, what i mean is how to name a server when creating it, I can only find StartHost() and StartServer() where none of them takes a parameter.
A server browser needs a dedicated matchmaking system which you'd permanently host on a separate server. Steamworks is your best bet though you can use others.
When I click host the player prefab spawns which is great! Though when I go to click join with the other client I get a timeout. Using localhost and such, I am unsure where I went wrong. Been looking through all day for a solution. Hopefully I will come across something.
I did this, but my Roomplayer prefab doesn't create, but he is in the network manager as player prefab and player room prefab, what could i have done wrong? Edit: i found it for some reason my MenuScene string does not work so i needed to hardcode it like this == "Lobby"
for some reason the continue button on the external build doesn't enable when i type my name. but when i test it in unity itself it works fine. any suggestions what causes this issue?
[Solved] it seems like everything with the connection and UI works, but i cant see the roomplayer objects. yes i assigned them in the inspector of the network manager Edit: i wrote the Function for the Host not for the client xD
Hi, I'm also having the same button issue. I noticed that I could press it once before i put any text into the Inputfield but then once I did, every time i ran the game after that I was unable to press the confirm button. :( EDIT: G Chozick has a method that fixed it for me. When you on the "InputField_Name" you change the OnValueChanged from a static to dynamic.
@@kyleweeks761 late reply but: put name = nameInputField.text; before the continuebutton line in SetPlayerName the name string is actually not linked in any way to the input field in the original code which is why it will always return true to the isnullorempty and the button will always be noninteractable
hi, i have a strange issue, when client join i can see in server the new prefab, but it's created over the prefab of the server, so on the server i can't press any button couse they'r covered by the client prefab. any ideo to fix it?
Your tutorial is awesome ..! I've got a question. what if i want to connect to my friend's game but i use different network connection. So what should i do?
Hello, I love your tutorials Dapper, thank you so much! Also is there a way to generate a join code rather than using an IP address and if so will you add it in a tutorial or github (not a request just a question)?
Spawning in the registered prefabs doesnt work for me- every time it throws me this message- Replacing existing prefab with assetId '[assetId of Prefab]'. Old prefab 'RoomPlayer', New prefab 'RoomPlayer' UnityEngine.Logger:Log(LogType, Object) Any help here? i'm really stuck on this.
I have a question, suppose i have different network managers for different scenes and i set DontDestroyOnLoad to false, how does it work with scene change ? does it work just like that or do you have to do something to make it work ?
Hey one question does this work also by remote or only for local clients? Btw those tutorials are really cool. Also i'm having a problem whith the input field that doesn't work: when i click on it nothing happens
You can either look up how to port-forward for your router or look into using stream as a relay: th-cam.com/video/QlbBC07dqnE/w-d-xo.html&ab_channel=DapperDino
Hey Dapper sorry if i take your time with those questions but i would like to know if you already did a video about interracting with objects or spawn objects or other similar things in a multiplayer game. Sorry again
when i enter the ip address it doesn't take me into the lobby. and it comes with the error "could not resolve the host" and then after that it would say whatever name i have put in
Hey Its possible for you to make a tutorial about syncing Mirror + Fizzy + Steamwork ? I use Steamwork complete V2 with Mirror and FizzySteam , I follow your tutorial , But I don't understand how to link correctly my networkManager and my LobbyManager from Steamwork. :/
when you're the host, you need to StartHost instead of StartClient in JoinLobby of JoinLobbyMenu. This wasn't mentioned in the video. otherwise, great tutorial.
Is there a reason why OnStartClient has to foreach the same prefabs folder that OnStartServer can just put in spawnablePrefabs? Its the same method right?
thank you for the tutorial, so far, I have the host game or start game running, but for some reason, my other app that is on my unity studio, i run it, and try to click join, doesnt go... it just disconnects or times out... i run it to connect local host and made sure my firewall is turned off... I tried the network manager actual mirror... and it runs fine... any ideas? anything i can paste or send you that could help figure this out?
Search for the Mirror Component NetworkDiscovery. With that you can Broadcast your server on lan (AdvertiseServer) and also search for available Servers
As soon as my client connects I get this warning: KCP: received unreliable message in state Connected. Disconnecting the connection. Any ideas? I'm using ParrelSync rather than building the game.
@@nasostsionas Unfortunatly, no. I tried changing from kcp transport to telepathy transport on the networkmanager object (as Dapper has in his video). Now I instead get the following message when the client joins the server: ReceiveLoop: finished receive function for connectionId=1 reason: System.ObjectDisposedException: Cannot access a disposed object. Object name: 'System.Net.Sockets.NetworkStream'.
Yea, there is definatly something wrong with the custom network manager. There are no issues to connect when using the default network managers. I'm trying another tutorial to see if that works better
@@Hairclone Yeah I agree with you because me too I have no problem connect with the default network manager (even through internet) but with the custom network manager I always get that damn error :'(
@@nasostsionas The error is in the OnServerConnect method. For me it somehow always thinks that the menu scene is NOT active and disconnects. Try reconnecting the client once more after the error or comment out that part of code and see if it works out for you.
I also had the problem where the RoomPlayers weren't showing in the Hierarchy after players were joined. To fix this I had to update the OnClientConnect / OnClientDisconnect functions in NetworkManagerLobby.cs: public override void OnClientConnect() { base.OnClientConnect(); OnClientConnected?.Invoke(); } public override void OnClientDisconnect() { base.OnClientDisconnect(); OnClientDisconnected?.Invoke(); }
Im pretty sure its not supposed to happen, but when I test it out, it crashes the game. Im not sure where I went wrong, becuase it doesn't really give a reason why
I really hope I didn't miss anything, but for some reason it doesn't allow me to click in the Input Field in the first place. Does anyone know what could be the problem??
Anyone know what the question mark in "OnClientConnected?.Invoke()" is for at 5:53? Thanks! Edit: Seems like it is required for invoking any system event. Still curious about it though.
we used a delegate. A delegate is basically a variable that holds function(s). So when you call the delegate, any functions that are in the delegate will be called. If there are no functions that means the delegate is null. So "OnClientConnected?.Invoke()" is basically a wierd shortcut of saying " if (OnOnClientConnected == null){ OnOnClientConnected(); } "
He uses the namespaces to organize things. Don't copy the entire files over if you don't want to type the methods up yourself. Take only the class and the includes.
I am not able to add the room player prefab as the player prefab in the network manager lobby. I get the error that player prefab must have NetworkIdentity. My room player does have the network identity component. And I have applied the changes to the the prefab as well. It still won't let add it to the network manager. Please help me.
Ok if anyone has this problem, the issue is you might have added the standard network identity, and not the one from Mirror. After fixing this, it should work.
No, It's using a networking solution called Mirror. He has another video where he shows you how to set it up, and the thumbnail is a multiplayer remake of pong. Hope this helped!
Hi, iam facing collision detecting issue with raycast in addtitive scene in multiplayer game. player not able to detect other objects in additive scene but on mainscene it works.Can anyone help me with this fix?
Currently both of the lobby UI's spawn on the host's client. I tried moving everything from OnServerAddPlayer to OnClientConnect, which fixed that problem but then the OnStartClient on the spawned object would not be called. If anyone has a fix lemme know
I want to create an online multiplayer board game. It should be like, one person creates a game, and his friends living in other city or country should be able to connect to him. Will mirror help me do this?
i also think routers block those connections on port 7777 for example so you would have to do something called port forwarding. Correct me if i'm wrong.
I have a same issue, I thought that my stuff was not working even after making sure that my scripts and setup look exactly like his. I downloaded the source code for this tutorial from github, tried using his project and it worked for hosting/joining a server couple of times and then it stopped, the players would not be instantiated into the room.
For some reason, when I start host, its fine, the secondary client, is able to connect, BUT when I look at host, I don't see RoomPlayer(Clone) prefabs being created for the one hosting and the other joining... i checked... I am pretty close to exactly what is on the tutorial... BUT like couple of things people in the comments pointed out, some minor issues and fixes... anyone else come across this issue?
@@ThePro-ng4yt Cool thanks, your right, I used the Network manager, and it works, the client shows up, not sure why the RoomPlayer(clone) doesn't show up when using the NetworkManagerLobby :(
I copied the code line for line and validated it against your github repo, my UI looks a lot different but has all the same components. I can successfully host a server and successfully establish a connection from the client but it immediately disconnects. Does anyone have an idea of what might be causing this? There are no errors other then just disconnected message.
BIG thank you to stefan429, he is right, well the things he mentioned in his comment:
if youre having issues, MAKE SURE:
1. your networkManager has the roomPlayer prefab assigned at the bottom
2. youre using path instead of name for checking the active scene in both OnServerConnect AND OnServerAddPlayer in NetworkManagerLobby, i.e. SceneManager.GetActiveScene().path
so for number 2, in detail, in the youtube tutorial, it shows:
if(SceneManager.GetActiveScene().name != menuScene)
{
conn.Disconnect();
return;
}
BUT you need to change it to:
if(SceneManager.GetActiveScene().path != menuScene)
{
conn.Disconnect();
return;
}
that fixed the problem... ONE LAST thing i am trying to figure out, is my lobby, the Roomplayer prefabs never show up on the Left side that shows the tree and the objects... not sure why :(
Thanks man!
Helpful comment upvoted!
same problem, when a client joins the lobby it sais : server disconnect, connection id1, please let me know if you've solved the problem
@@meddjihed9108 If you have the bug where Roomplayer doesn't get instanciated:
NetworkManagerLobby.menuScene doesn't get converted to the rigth string, so
if (SceneManager.GetActiveScene().name == menuScene)
won't be true.
Fix this by making
[SerializeField] string menuScene;
And type in the scene name in the inspector instead of dragging in the scene.
Used Unity 2020.1.6f1
Credit:- @Julian Röckl
Life saver !
What I reccomend for ur clips to use diffrent workflow or order when u record this tutorials, first show us UI then code. This way u keeping trowing new files and scipts, but when u create it I do not know why do u need that new script, so script doesnt make sense until I see UI and then I need to scroll through scipts again to understand why I wrote some methods. In this alternative I will understand it first time, while I am writting code. But thank u for ur work anyway, keep going :D
Yeah I think he should do the UI first before the scripts, because I gave up right after the UI
I second this because our UI is usually different from your UI and it's better to know in advance what parts of your code we should ignore and it's also really confusing when you mention all these different scripts but we don't even have a visual representation yet of why we are doing it this way, this does cause us to have to jump back and forth a lot.
Thanks for these excellent tutorials, hope you don't mind our feedback.
1:00 - Coding
5:51 - Setting Up UI & Prefabs
11:15 - Testing
I get a little lost, trying to figure out what code we are supposed to create, and what code comes with Mirror. I definitely love it when you show us your screen while you type it out.
Either way it is a great tutorial, and definitely helps us create a network lobby without any experience. Thank you!
Yeah i also Like him while Explaining and Typing but its okey
ClientScene was merged into NetworkClient on the mirror docs
thx dude, you are the best
thx
ur a G
Thank you!
If you have the bug where Roomplayer doesn't get instanciated:
NetworkManagerLobby.menuScene doesn't get converted to the rigth string, so
if (SceneManager.GetActiveScene().name == menuScene)
won't be true.
Fix this by making
[SerializeField] string menuScene;
And type in the scene name in the inspector instead of dragging in the scene.
Used Unity 2020.1.6f1
Thank you so much! I wonder if this is a bug or if it's just a weird way Unity handles the string from a scene.
thank you mate :) This fixed my issue.
alternatively, you could use GetActiveScene().path instead of the `name`, because the menuScene variable returns the asset path instead of asset name.
@@fadhil0o0o0 Sonds like a better solution, didn't knew that. Thanks for pointing it out!
thank you so much, this was the issue i had for so long
The fact that u have every program on your taskbar open (even league of legends) triggers me XD
A big hug from Brazil, Thanks so much
Its a really good tutorial but you should explain more thoroughly or go slower , i was stuck trying to figure out why my intelisense would not recognize the event action bit and in the end i realized is because i was missing using system. But overall a really great tutorial man.
Thank you. This comment helped me a lot, I had the same issue.
Make sure you check out the project in github too - that's how I fixed all my missed imports that were throwing errors :) my ide is awful at picking up intellisense haha
public void SetPlayerName(string name)
{
continueButton.interactable = !string.IsNullOrEmpty(name);
}
this line of code is broken for no reason. But it got fixed with
public void SetPlayerName(string name)
{
continueButton.interactable = nameInputField.text.Length >= 4;
}
I do not know why it got fixed
Thank you
thanks kkk
You can change the line below to make "continueButton.interactable = !string.IsNullOrEmpty(name);" work
private void SetInputField()
{
if(!PlayerPrefs.HasKey(PlayerPrefsNameKey)) { return; }
string defaultName = PlayerPrefs.GetString(PlayerPrefsNameKey);
nameInputField.text = defaultName;
SetPlayerName(defaultName);
}
to
private void SetInputField()
{
if(!PlayerPrefs.HasKey(PlayerPrefsNameKey)) { nameInputField.onValueChanged.AddListener(delegate { SetPlayerName(nameInputField.text); }); ; return; }
string defaultName = PlayerPrefs.GetString(PlayerPrefsNameKey);
nameInputField.text = defaultName;
SetPlayerName(defaultName);
}
I think it would be better if you wrote the code in front of us so that we can see all the code and understand what is happening in the code
Would love some help - My unity player launches the lobby fine when I host, when I join the localhost on the build version it joins but all it says is "Lobby Tutorial" it doesn't create another player. I'm not getting any errors. Thoughts?
I have exactly the same problem. Its even saying in the console, that another player joined
@@davidandrestorresbetancour6527 Thanks!
same problem
How to make sure that players create all lobbies on one server, and not connect via IP?
THANK YOU for your tutorials. Great tuts, great channel, great tutor.
You're welcome :) Glad I could help
Amazing video, clear and concise explanations at every step. Really helped break down the process of setting up a lobby, which I've been too daunted by before now to get any further than the first couple of files on my own! Thank you so much :)))))
Thanks! Also I like the fact that you have LoL opened in background.
i'm having trouble navigating the Git Hub page, many files seem to be deleted, is it a mistake on my part?
thank you very much for this tutorial
if I host a game on unity my roomplayer instantiated but if ıtry to join a game in build another room player couldn't instantiate. Can someone help me
the "confirm" button for the name UI needs to be "interactable" in order for it to be clickable. It was unchecked by default, and it wouldn't allow the UI to move onto the next page.
Guys help me, my "Empty" object is not spawning, and neither is the "NetworkGamePlayerLobby" prefab. It's all set right in NetworkManager.
if anyone knows please help me.
It would appear there is no function called OnClientConnect() in the class NetworkBehaviour. Has it been removed in some update since this video, or has it changed name?
change the NetworkBehaviour to NetworkManager
@@X_TYR_X Alright, thank you!
I'm following your wonderful series (which you said it is not a series ahahah), anyways, is there the possibility to create multiple lobbies contemporarily to which the users can connect by a name or an ID? I mean private lobbies for groups of people
Nice video, cant wait for the others
Me either :D
After following this video and the next one in the playlist, I'm having trouble connecting a client to the host. I've ensure the transport IP is localhost, but still no results.
If it helps, the logs show the host accepting the connection and then the client immediately disconnects. On the flip side when running a client in editor and attempting to join the lobby by specifying "localhost", the only message that appears is a timeout message.
Any ideas what could be going on here?
I actually solved the issue on my own after taking a break and coming back to this. The menuScene variable doesn't store the correct value. I simply hard-coded it to the value of "Scene_Lobby" to get it to work. Hope this helps anyone who might be having this problem!
what was the first game you created when you were beginner?
BTW i loved this tutorial :)
Thanks :) Have a look at this: th-cam.com/video/5aTRbxUWrI4/w-d-xo.html
thanks for the great tut! I'm having a really weird issue, where i am trying to override methods from the NetworkManager but it says that no suitable method can be found. I swear I'm inheriting from the base class correctly
Okay, I solved the problem for anyone who might be interested, the problem was that i had another package installed (called rasa, a chatbot framework) which also had a class called NetworkManager which I was inheriting from. Oops
I have the same issue but I dont have any packages like that and I dont know what to do or how to check for any packages that might have that
How do I make rooms available from the server, when clients connect to the server will see those rooms?
each server is a room
When I follow your code and try running, I don't see the two objects instantiated in the Hierarchy. Is this supposed to happen?
Have you found out how to solve it? Exactly the same problem xD
@@BSalabert did you dfind out how to solve it?
Guys I found the problem, since I had the same ^^
using [Scene] [SerializeField] private string menuScene;
results the string being "your current path to the assets folder + path to your scene + scene name".
Now in the OnServerConnect method we check if the client tries to join an ongoing game, where we check if(SceneManager.GetActiveScene().name != menuScene).
That results in checking the hole path string against just the scene name.
So the Client gets disconnected immediately and the roomPlayer doesnt gets instantiated.
If you fix the string menuScene, to only contain the actual scene name, it will work properly ! :D
@@Frenuellcrackser33 i now get a error saying the object i want to instantiate is null, i've bene looking for a while but cant find a answer, would you be able to point me in the right direction? also thanks for the previous fix :) the error is with the instantiation of roomplayerprefab in Networkmanager
@@asdfbasdfabwe make sure that rhe RoomPlayer Prefab is referenced in the NetworkManager(Lobby) script in your scene. For the Player Prefab aswell as the Room Player Prefab.
I'm getting a 'no suitable method found to override' error for both the OnServerAddPlayer method and the OnServerConnect method. Any solution? thanks in advance :)
me too, I'm also having that issue:
[EDIT]
Found out why and how to fix it:
change "public override void OnServerDisconnect(NetworkConnection conn)" to "public override void OnServerConnect(NetworkConnectionToClient conn)"
This is a lovely tutorial! It really helped me get started in building a LAN lobby, and saved me hours of time and headache !
However.. I was wondering if it was possible to connect using a room name instead? Something like substituting the IP address with the room name when the lobby is created
I am having trouble doing that and the system can only recognise the network address being changed locally, while the network address of the host is something like 'my room', in the client, it registers as 'localhost' still.. Any help would be much appreciated, I've spent so much time trying to figure this out and am unable to do much about it >
Sure, but you need a backend solution for that. It should store map with ip_address => room_name and when user sends room name to server, it should resolve it with ip address.
@@mikekozlov3484 Thank you for the reply! I've decided to use another way for network discovery but this is very useful to know!
@@littledumpling5614 Hello! I used another method, so if you're looking for how to do something similar to what I wanted to using the localhost method, I'm afraid I can't help you. If you'd like to know the other method however, I'll explain a bit about it!
So rather than have my players input the IP or localhost, I decided to use Network Discovery instead.
Basically, NetworkDiscovery, upon starting a local host, will advertise it as a server, so all clients will be able to see it when they look for a server, and will then be able to join it!
It's also possible to display a list of servers active, I didn't do it for my project because it isn't needed. The built-in script does make that work though, so I recommend experimenting with it.
Here's what I used to get started: mirror-networking.com/docs/Components/NetworkDiscovery.html?q=network%20discovery
All the best!
YO thanks, but i was wondering, does this work only for local clients or can i connect to servers remotly?
@@radue9658 I'm afraid I don't really know the answer to that, so you'll have to experiment and try it out yourself, all the best!
PlayerPrefs is volatile right. It's only accessible till the app cache is uncleared. When the player clears the cache then the data saved is gone right?
Great video, been needing to do this for my own game
Nice! Hope it helps :)
It doesn't connect when pressing join
Thank you very much for this effort👍
No worries!
اخي مهدي.. هل اللوبي هنا يعمل كنظام البلوتوث ؟ يعني اللاعبين القريبين من بعض فقط ؟
Thanks for the tutorial! One question though. In the "OnServerAddPlayer" function, why did you instantiate the roomplayerprefab instead of a player prefab. Is there a reason for this?
same problem, do you find any solution???
@@A_Reaper23 The reason is, I guess, this script is only making players join the Lobby Room and not the Game itself. Things like PV, Mana and else that we could need in game won't be usefull in lobby so we can use different prefabs.
(I hope you did find your answer before but just in case you didn't ... ;) )
Whenever I join lobby on my remote build after hosting a lobby it connects, creates player, than instantly disconnects. It goes onEnable, joinLobby, onStartClient, onClientConnect, handleClientConnected, onDisable, onClientDisconnect. Did anyone have a similar issue?
Having the same issue, has anybody found a solution to this problem? The roomplayer gets instantiated on host but as when I go to join on a different computer the OnServerAddPlayer() method is not even called, I then am promptly disconnected.
@@Imdad6629 I have solved the problem with me hope it can help you and also the others if someone has the same problem. so go to the game object "NetworkManager" where you also have the NetworkManagerLobby script on it, with me has there always automatically created the Kcp transport that's wrong delet it. search for "Telepathy Transport" at component and link it in the inspector in the NetworkManagerLobby script.(my english is not so good i hope it helps u out :)
Hey Dapper Dino ^^
I really appreciate these tutorials!
I learn a lot from you and it's great.
I've looked at the Mirror documentation because I really want to be able
to name my lobby, your tutorial showed how to connect directly via. IP address, but if I want a server list, surely I would also want names for servers.
Could you perhaps show how to do that?
I've looked around the internet for days and can't find anything.
Thank you in advance :)
To clarify, what i mean is how to name a server when creating it, I can only find StartHost() and StartServer() where none of them takes a parameter.
Yeah me too man I wish he do it
Me too
A server browser needs a dedicated matchmaking system which you'd permanently host on a separate server. Steamworks is your best bet though you can use others.
any good advice if I want to use a join code to join a lobby using mirror?
When I click host the player prefab spawns which is great! Though when I go to click join with the other client I get a timeout. Using localhost and such, I am unsure where I went wrong. Been looking through all day for a solution. Hopefully I will come across something.
Did you find a solution? Been debugging for hours
I did this, but my Roomplayer prefab doesn't create, but he is in the network manager as player prefab and player room prefab, what could i have done wrong? Edit: i found it for some reason my MenuScene string does not work so i needed to hardcode it like this == "Lobby"
@Jadran Zagorac thank you for this!
Legend! Thank you!
@Jadran Zagorac Thank fucking god for this.
Is it possible to run multiple lobbies at the same time ?
for some reason the continue button on the external build doesn't enable when i type my name. but when i test it in unity itself it works fine. any suggestions what causes this issue?
Use the dynamic function
@@fazesponge1422 how?
[Solved]
it seems like everything with the connection and UI works, but i cant see the roomplayer objects. yes i assigned them in the inspector of the network manager
Edit: i wrote the Function for the Host not for the client xD
I think I'm having the same problem, which function are you referring to?
@@Snerlerx it was the OnStartHost function, you have to change it to OnStartClient
@@FireJojoBoy Didnt work :/ thanks anyway
@@Snerlerx have you tried changing the getActiveScene.name to getActiveScene.path ?
If I chance my username when I want to connect there is no error but I can't click that confurn button so I need to play as "enter name..."
Did you solved the problem? I have a same issue :(
Hi, I'm also having the same button issue. I noticed that I could press it once before i put any text into the Inputfield but then once I did, every time i ran the game after that I was unable to press the confirm button. :(
EDIT: G Chozick has a method that fixed it for me. When you on the "InputField_Name" you change the OnValueChanged from a static to dynamic.
@@kyleweeks761 late reply but:
put name = nameInputField.text; before the continuebutton line in SetPlayerName
the name string is actually not linked in any way to the input field in the original code which is why it will always return true to the isnullorempty and the button will always be noninteractable
@@thelittlechemist941 THANK YOU THANK YOU THANK YOU!!!!
hi, i have a strange issue, when client join i can see in server the new prefab, but it's created over the prefab of the server, so on the server i can't press any button couse they'r covered by the client prefab. any ideo to fix it?
Your tutorial is awesome ..! I've got a question. what if i want to connect to my friend's game but i use different network connection. So what should i do?
this is really hard to follow, i would really prefer showing us the process of you coding each part even if it takes longer
Hello, I love your tutorials Dapper, thank you so much! Also is there a way to generate a join code rather than using an IP address and if so will you add it in a tutorial or github (not a request just a question)?
FINALLY ONE THAT ISNT FROM 69 YEARS AGO HOLY SHIT
Thanks a lot for doing this
How can I make it Multiplayer out side of just the same network connection?
Spawning in the registered prefabs doesnt work for me-
every time it throws me this message-
Replacing existing prefab with assetId '[assetId of Prefab]'. Old prefab 'RoomPlayer', New prefab 'RoomPlayer'
UnityEngine.Logger:Log(LogType, Object)
Any help here? i'm really stuck on this.
check out the solutions from @scribl1 and @Coldsandwich. it resolved this issue for me.
Thank you so much Dapper
I have a question, suppose i have different network managers for different scenes and i set DontDestroyOnLoad to false, how does it work with scene change ? does it work just like that or do you have to do something to make it work ?
Hey one question does this work also by remote or only for local clients? Btw those tutorials are really cool.
Also i'm having a problem whith the input field that doesn't work: when i click on it nothing happens
You have to create an event system. Top left plus icon > UI > event System
Thanks, I solved it but fo you know if this works also for remote clients that connect using the IP addresses?
You can either look up how to port-forward for your router or look into using stream as a relay: th-cam.com/video/QlbBC07dqnE/w-d-xo.html&ab_channel=DapperDino
@@DapperDinoCodingTutorials yo thanks Dapper Dino, I appreciate a lot
Hey Dapper sorry if i take your time with those questions but i would like to know if you already did a video about interracting with objects or spawn objects or other similar things in a multiplayer game. Sorry again
when i enter the ip address it doesn't take me into the lobby. and it comes with the error "could not resolve the host" and then after that it would say whatever name i have put in
what for ip u typed in are u on the same network on both devices?
i'm getting an error in the networkmanagerlobby script saying that the name 'ClientLobby' does not exist in the current context. How could i fix this?
Hey Its possible for you to make a tutorial about syncing Mirror + Fizzy + Steamwork ? I use Steamwork complete V2 with Mirror and FizzySteam , I follow your tutorial , But I don't understand how to link correctly my networkManager and my LobbyManager from Steamwork. :/
when you're the host, you need to StartHost instead of StartClient in JoinLobby of JoinLobbyMenu. This wasn't mentioned in the video. otherwise, great tutorial.
Is there a reason why OnStartClient has to foreach the same prefabs folder that OnStartServer can just put in spawnablePrefabs? Its the same method right?
Room player prefab doesn't spaw when hosting and joining, any idea on how to fix this ?
How do you list existing lobbies to choose from rather than just inputting the lobby name? Where is that info hosted to?
thank you for the tutorial, so far, I have the host game or start game running, but for some reason, my other app that is on my unity studio, i run it, and try to click join, doesnt go... it just disconnects or times out... i run it to connect local host and made sure my firewall is turned off... I tried the network manager actual mirror... and it runs fine... any ideas? anything i can paste or send you that could help figure this out?
Can you just join a random game instead of entering an address?
yes
@@0x19 but how do we do that?
Idk actually still learning mirror but i did the random join thing before in a Minecraft plugin
Search for the Mirror Component NetworkDiscovery. With that you can Broadcast your server on lan (AdvertiseServer) and also search for available Servers
I dont know why, but my overrides dont work
Did you solved it?
@@augustoantenucci4725 Use NetworkManager instead MonoBehaviour or something
@@eloreneloreneloreneloreneloren thanks
@@augustoantenucci4725 delete all scripts from the prefab, then go to the prefab in the scene and add the scripts
As soon as my client connects I get this warning: KCP: received unreliable message in state Connected. Disconnecting the connection. Any ideas? I'm using ParrelSync rather than building the game.
did you found anything on this?
@@nasostsionas Unfortunatly, no. I tried changing from kcp transport to telepathy transport on the networkmanager object (as Dapper has in his video). Now I instead get the following message when the client joins the server:
ReceiveLoop: finished receive function for connectionId=1 reason: System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'System.Net.Sockets.NetworkStream'.
Yea, there is definatly something wrong with the custom network manager. There are no issues to connect when using the default network managers. I'm trying another tutorial to see if that works better
@@Hairclone Yeah I agree with you because me too I have no problem connect with the default network manager (even through internet) but with the custom network manager I always get that damn error :'(
@@nasostsionas The error is in the OnServerConnect method. For me it somehow always thinks that the menu scene is NOT active and disconnects. Try reconnecting the client once more after the error or comment out that part of code and see if it works out for you.
i need to make the network mannager if im using mirror?
I also had the problem where the RoomPlayers weren't showing in the Hierarchy after players were joined. To fix this I had to update the OnClientConnect / OnClientDisconnect functions in NetworkManagerLobby.cs:
public override void OnClientConnect()
{
base.OnClientConnect();
OnClientConnected?.Invoke();
}
public override void OnClientDisconnect()
{
base.OnClientDisconnect();
OnClientDisconnected?.Invoke();
}
How to auto start, so that player can join if there are any matches having some vacancy else can host a game. Please reply. Thank you in advance 👍
Im pretty sure its not supposed to happen, but when I test it out, it crashes the game. Im not sure where I went wrong, becuase it doesn't really give a reason why
Question, is it possible to connect to someone else's match from two seperate LAN?
Can I use proton and mirror?
Why is the IP address bar entered the localhost? and are you able to create more than one server if multiple groups of people want to play?
I really hope I didn't miss anything, but for some reason it doesn't allow me to click in the Input Field in the first place. Does anyone know what could be the problem??
the continueButton dosent get interactable after type in username what should i do?
Anyone know what the question mark in "OnClientConnected?.Invoke()" is for at 5:53? Thanks!
Edit: Seems like it is required for invoking any system event. Still curious about it though.
This is the action check for null, "?" is like "Invoke, if we have what to invoke"
we used a delegate. A delegate is basically a variable that holds function(s). So when you call the delegate, any functions that are in the delegate will be called. If there are no functions that means the delegate is null. So "OnClientConnected?.Invoke()" is basically a wierd shortcut of saying
" if (OnOnClientConnected == null){
OnOnClientConnected();
}
"
How would I find a random match? Im making a game where you verse other people, but I dont want to use IP address
Using the code from the github created tons of namespace errors among others too, any fix?
same problem
He uses the namespaces to organize things. Don't copy the entire files over if you don't want to type the methods up yourself. Take only the class and the includes.
I am not able to add the room player prefab as the player prefab in the network manager lobby. I get the error that player prefab must have NetworkIdentity. My room player does have the network identity component. And I have applied the changes to the the prefab as well. It still won't let add it to the network manager. Please help me.
Ok if anyone has this problem, the issue is you might have added the standard network identity, and not the one from Mirror. After fixing this, it should work.
Is this local multiplayer only???
No, It's using a networking solution called Mirror. He has another video where he shows you how to set it up, and the thumbnail is a multiplayer remake of pong. Hope this helped!
Thanks man, you're my god.
Hi, iam facing collision detecting issue with raycast in addtitive scene in multiplayer game. player not able to detect other objects in additive scene but on mainscene it works.Can anyone help me with this fix?
Currently both of the lobby UI's spawn on the host's client. I tried moving everything from OnServerAddPlayer to OnClientConnect, which fixed that problem but then the OnStartClient on the spawned object would not be called. If anyone has a fix lemme know
wonderful,thank you.
Great video
Thanks :)
Can u do a discover hud version?
At 1:06 what's the namespace for? Is it important?
the namespace is not important i think it is only so that you can access other scrips easier i think. i havnt used it and mine still works
namespace is essentially categorizing something within a folder, its to help management of your scripts
when i click on host lobby i get this error message "NullReferenceException: Object reference not set to an instance of an object"
There is one object that is Not assinged top the script i think(sorry my Englisch is Not so good)
I want to create an online multiplayer board game. It should be like, one person creates a game, and his friends living in other city or country should be able to connect to him. Will mirror help me do this?
yes. You should host a lobby with your external IP address
i also think routers block those connections on port 7777 for example so you would have to do something called port forwarding. Correct me if i'm wrong.
Me: Copies code into Unity
Unity: 8 ERRORS
Me: 8?!
I have that issue too, usually something small Ive missed, or just version differences,
What does it mean if when clicking host lobby, the RoomPlayer prefabs are not being created?
I have a same issue, I thought that my stuff was not working even after making sure that my scripts and setup look exactly like his. I downloaded the source code for this tutorial from github, tried using his project and it worked for hosting/joining a server couple of times and then it stopped, the players would not be instantiated into the room.
@@tomasutaravicius7545 Did you ever figure out how to fix this?
Please make a tutorial on how to integrate mirror with sql database
Btw great vid as always :)
please help it always says cannot resolve host
It is spelled "eelyA gavrEElov" Dapper Dino san)) Upper cases are the stress letters
For some reason, when I start host, its fine, the secondary client, is able to connect, BUT when I look at host, I don't see RoomPlayer(Clone) prefabs being created for the one hosting and the other joining... i checked... I am pretty close to exactly what is on the tutorial... BUT like couple of things people in the comments pointed out, some minor issues and fixes... anyone else come across this issue?
@@ThePro-ng4yt Cool thanks, your right, I used the Network manager, and it works, the client shows up, not sure why the RoomPlayer(clone) doesn't show up when using the NetworkManagerLobby :(
Thank you so much!
how i can't fix this plz
input axis horizontal his not setup pl help
im new for this i don't now sow match about unity plz help
Are you on about this video?
@@DapperDinoCodingTutorials no just to move,movement
I copied the code line for line and validated it against your github repo, my UI looks a lot different but has all the same components. I can successfully host a server and successfully establish a connection from the client but it immediately disconnects. Does anyone have an idea of what might be causing this? There are no errors other then just disconnected message.
I get the same issue, any luck?
@@tamerxero unfortunately no :(
Is there a limit players?
Thank you so much