❤ Watch my FREE Complete Multiplayer Course ruclips.net/video/7glCsF9fv3s/видео.html ✅ Learn more about Relay and UGS on.unity.com/3tQZLLW 📝 Relay Docs on.unity.com/3OjXL8z 🔴 RELATED VIDEOS 🔴 COMPLETE Unity Multiplayer Tutorial (Netcode for Game Objects) ruclips.net/video/3yuBOB3VrCk/видео.html Join your Players in MULTIPLAYER with Lobby! (Unity Gaming Services) ruclips.net/video/-KDlEBfCBiU/видео.html What is Unity Gaming Services? ruclips.net/video/JwClCc2_zC8/видео.html EASY Console! Run any Command! (Add Cheats, Set Gravity, Spawn Enemies Quantum Console Asset Review) ruclips.net/video/bOf6CjpuSFs/видео.html 🌍 Get my Complete Courses! ✅ unitycodemonkey.com/courses 👍 Learn to make awesome games step-by-step from start to finish. 🎮 Wishlist my Next Steam game! cmonkey.co/totalworldliberation
Imagine that I'm watching your tutorials then directly testing and trying, and when I tried to make a starting game function I didn't find any way, and I lived a week of hard researching, until I thought "let's just go and see Code Monkey's next video, maybe it has something helpful", then when I heard in 0:57 "the host starts the game" my hopes and dreams started floating in my mind. Thank you!!!!
I cannot stress enough how helpful this would've been about half a year ago for me. I tried to make an online lobby system using only NGO, but had troubles with connecting and even had to turn off my Windows Defender for it. Seeing this tutorial makes me really happy, and I'll definitely be saving this one for the future.
This is the video I was waiting for! I needed a vision for how these services fit together, and the end of this video did that for me. One huge thing for me that would have been helpful that I'm just now learning is when to implement these different packages in your game development cycle. The whole time I was starting to implement Netcode I was worried that I'd have to redo all of my work as soon as I wanted to add Relay and Lobby, since I didn't understand them. What I learned from these 3 tools was: 1. Implement Netcode from the beginning, the longer you wait the bigger headache it is to implement. 2. Lobby and Relay can be implemented relatively whenever, and implementing them later in the project doesn't have huge cons. (The only real con is if you already had a lobby screen and you needed to rewire it to use Lobby)
Yup that's definitely what I would do. If the game is intended to be primarily multiplayer then definitely get Netcode implemented as quickly as possible, the other tools can wait. I'm glad the video heped you, thanks!
A good use-case fort starting a relay already whilst in the lobby is something like Among us where in the lobby you can already run around and see each other :)
@@TheJangoo if i remember correctly there is a 1 hr video regarding netcode for game object on his channel. This video was after that. Also there is a 6 hrs tutorial on his channel as well.
CodeMonkey!, first of all, I have to admit strongly that you are really really amazing. You have saved and helped me many times and this is the first time I comment on your videos. There's no downside to your videos. Your content is really nice, clean, short, useful, without any extra time-consuming words. and besides, you really code so professionally. and you cover all the details. your videos are really well-designed. This playlist is really unique and astonishing. God save the CodeMonkey!
@@CodeMonkeyUnity Just one topic I haven't got. you just used lobby and relay and netcode gameobject to develop a multiplayer online game. the question of mine is, then what are Game Server Hosting (Multiplay) & Matchmaker for??! when do we have to use them while everything is done through relay and netcode?
This video is a godsend! I've been racking my brain trying to figure out how to set up relay for months until I finally found this video and now it seems so easy! Thanks CM!
Very cool. Thanks, as always, for the great information! It was a bit confusing there at the end when you tied Relay and Lobby together, but only because you did it with your downloadable "project example" and not with the TestLobby code you showed us how to create directly in the last tutorial. I do have the demo, however, and was already planning to take it apart & dissect it, so it should be fairly easy to implement once I've wrapped my head around the changes & additions you've made to the code there. I'm sure I'll be back to reference the end of the video again here very soon, so I'll just leave it open. Have a terrific day & thanks again!
At 8:52 I am getting this error: Unity.Services.Relay.RelayServiceException: You are not signed in to the Authentication Service. Please sign in. Please help
Thank you for your great videos! I have a problem at 8:52. I get the error: Failed to connect to player IP: CreateRelay:55000-55495,35000,4600,4600. Socket: Connection Failed, Error: A connection could not be established because the target machine refused the connection. could anybody help me?
Is that the full error? That's odd, at that point it should only be trying to contact the relay server to create it, it's not yet connecting anything like the NetworkManager. I would say make sure your Unity isn't being blocked by your firewall but if you can initialize the services and sign in then it's not being blocked.
I would also really, really like a video on how to set up a fresh game with a dedicated server. I've been trying to set it up myself, but it seems like a lot of steps are missing, maybe. I went through the example Battle Royale game, but it didn't answer all of my questions. I can't even get the server to recognize my command line arguments in the launch parameters. Thanks for the tutorials as always.
I have been able to make the game run but when I press the start game button, I get an error that refers to this line : "string relayCode = await RelayManager.Instance.CreateRelay();" And the error is a NullReferenceException which causes the game to not start. I believe I am missing something when it comes to the RelayManager script or in your case the TestRelay.
Could you also explain what imports you need to use for your code for your next video? It's a bit tedious having to pause the video at the right moment just to see what library I need to import in your IDE's auto-complete box.
Not sure what you mean by that, the only thing you need is the Relay package which I covered in the video. Are you talking about the "usings"? I paused for a while every time the IDE was automatically adding a new one
@@CodeMonkeyUnity yeah, the usings, like that moment in 12:11, the unity transport comes from another using that your IDE automatically set up. Your videos are great, it's just that I came from other "tutorials" (which are really just hand-holding not explaining anything) that tell you to use something that hasn't been implemented yet, and later in the video, they implement it, and it took me a while to realize it was just a 'using' and not something you were going to implement later lol. And yeah, this is more of my fault I missed it, so you don't really need to listen to me lol.
I used a VPN just to demonstrate how it can connect to an external IP and not just another PC on my local network. You just use Relay and it handles making that connection without worrying about firewalls or NAT
I am at about 16:20 and I keep getting errors saying " The type or namespace 'RelayServerData' could not be found" There is also another error saying that the name 'allocation' does not exist in current context. Please help, thanks😅.
I have Netcode 1.2.0 and Transport 1.3.0 but the RelayServerData constructor as you show in the tutorial doesn't exist here. I'm using the DLTS endpoint approach *var dtlsEndpoint = a.ServerEndpoints.Find(e => e.ConnectionType == "dtls"); * It works ok but it doesn't work around my firewall issues :(
Thanks a lot for these amazing tutorials on multiplayer handling, Code Monkey! Cheers from one Portuguese to another (margem sul here, I'm guessing we're kind of neighbors)
Hi, first wonderful video, but I've probably watched it over 10 times now and still have a list full with errors when I tried to bring lobby and relay together. Would it be possible for you, to publish the Unity Project or to copy the finished script (as it was at the end of the video) TestRelay and LobbyManager as an answer so that I can compare my script with those scripts?
What errors? The Lobby video has the downloadable project files, I didn't include the ones for this video because the Relay is just a dozen lines of code which are visible in the video
@@CodeMonkeyUnity Thanks for replying, I think I did everything like in the video but got a few errors. All errors are in the LobbyManager script: 1. "TestRelay" does not contain a definition for instance 2.again the same error message 3. Argument "2": Unable to convert System.EventArgs to LobbyManager.LobbyEventArgs. 4. No argument was specified that matches the formal parameter "value" of "Dictionary. Add(string, DataObject)". I am new to Unity so it would be great if you could help me.
@@funkfollow9754 It sounds like you really need to learn C# basics before you go any further unitycodemonkey.com/video.php?v=IFayQioG71A If you're a Unity beginner I would highly recommend you start with a simple singleplayer project. Making multiplayer games makes everything 10x more difficult
08:03 Code Monkey ~ "it really is that simple". Haha, not for me xD. I finished the Tutorial and its just amazing. I didnt use the Add on for the Console (40$), but i just made a Function that gets called by a Input GUI call and it works fine, for writing in the code and for creating i just made the button, when pressed to call the function.
@@VoiceOfTheFutureYU Its hard to explain. But i will try. You have to say when the button is pressed you call the function, in this case "start the server". So you dont have to write commands, even tho you could do one console from scratch its not that hard. Learn how to use the GUI and you will see, its very easy.
I made my entire game using Netcode for GameObjects / Lobby / Relay, and now I get +350 ping or RTT. Even with the boss game demo, my ping was +350. It's caused by my location. So, I tested Photon and my ping was 80. What alternatives do I have? Can I use Photon servers instead of Relay? How do I integrate that? Or what's an alternative to Relay? Please make a tutorial about that if it's possible.
That ping will depend on the relay server location, sounds like the closes relay is quite far from you But that ping, while it looks high, it is perfectly acceptable for the kinds of games that NGO was made for, co-op casual games, it's only an issue for hyper competitive super fast paced shooters The question of ping is not really related to the underlying toolstack you use. Photon or NGO will be mostly the same. What matters is you server architecture. Fastest is Dedicated server (close to you), then you have peer 2 peer, and last you have Relay.
Hello! I am learning to write server side code using c# sockets (TcpListener UdpClient etc). My problem is that I only know so far that the server should start working on the given ip and port. I don't want to use ready-made solutions (Mirror Photon etc) because I want to learn how to write code from scratch myself. I want to create a p2p logic game and I noticed at 12:42 that Relay returns ip and port. Question: Can I use these ip and port to start listening based on them and only then, when other players connect via Relay, will they connect to this ip and port? Thanks in advance for your reply Привет! Я учусь писать серверный код используя c# sockets (TcpListener UdpClient etc). Моя проблема в том, что я пока только знаю что сервер должен начинать работу на заданном ip и port. Я не хочу использовать готовые решения (Mirror Photon etc), потому что хочу научиться писать код с нуля сам. Я хочу создать игру по логике p2p и я заметил на 12:42 что Relay возвращает ip и port. Вопрос: Могу ли я использовать эти ip и port, чтобы на их основе запускать прослушивание и уже потом, когда другие игроки подключатся через Relay они будут подключаться к этому ip и port? Заранее спасибо за ответ
At 17:55 you said that you set the name to get a new player ID. I might have missed something but is it possible to have different authentication IDs on the same computer? This would help a lot for testing. Thanks
Yes, you call SetProfile when initializing the services and when using different profiles you get different auth id allowing you to have multiple builds running
When joining a relay allocation that already has the maximum members connected, JoinAllocationAsync does not throw an exception. Is there some other way to check whether joining the relay is possible?
The Lobby has downloadable project files unitycodemonkey.com/video.php?v=-KDlEBfCBiU I didn't make them for the Relay since the code is really simple, you can watch the code in the video and implement it If you want to see it as part of a complete game I also used Lobby and Relay in my Free Multiplayer Course unitycodemonkey.com/kitchenchaosmultiplayercourse.php
Great video as usual, I am very interested to see how would a dialogue system work with the open ai gpt-3 system, will you ever have the chance to cover that as I see there isn't any much explanation on this subject as it is relatively new so it would be nice fo you to explain it and I am sure a lot of people would love it. As always great job and keep up the good work
This looks great! I have a problem about this; When I host from editor, and connect from windows build, everything works great. But if I open 2 builds, and host from one and connect from other, client seem can't connect to the game. If I host from windows build, and connect from editor, this also works. So the problem is when I open 2 windows build and create & connect.
Just amazing! Awesome tutorial, I have learned a lot. I was wondering if could could make a video that explains how to utilize the private lobby functionality, because currently, setting the lobby to private, there's now way to join it haha. Also, an example of how to make a screen with a "quit" button upon pressing escape would be great (not talking about the UI, but rather what do we need to cleanup when a player exists/lobby is destroyed upon host exit) Another suggestion is a loading screen while the relay is loading or something. But I know that's already too much lol... these are just suggestions!
If you set the Lobby as private you join it with the Lobby code You don't need to handle clean up manually, if all players leave the Lobby Unity will automatically destroy it
@@CodeMonkeyUnity On LobbyManager: in CreateLobby() = in data KEY_START_GAME(" The name "KEY_START_GAME" does not exist in the current context") in HandleLobbyPolling() = if (!IsLobbyHost()) TestRelay.Instance.("Test Relay , does not contain a definiton for Instance") onGameStarted? ("The name onGameStarted does not exist in the current context") in the StartGame() at the await TestRelay.Instance.CreateRelay(); ("does not contain definiton of Instance")
Nn the unity transport there is field for Adress and Port. What am i supposed to put there. Does it even matter? currently i have on localhost ip but will that work if i send the build to a friend?
How would I go about making the player update older builds as I release updates. Would the game break if players from different builds joined the same server?
Tried the built in relay sample after having issues switching over to it on something else, and it gave the same error when trying to join from a second client "Join code not found". Then tested the second example, it states allows testing from multiple clients, which occasionally gives the same error but for the most part works. Had to watch you give a paid for tutorial to see it is because a connection must be established within an arbitrary time frame. Still cant get it to run properly in my initial project, yet other network transports work without any issues.
Thank you for your tutorial. One more question! If we have one scene for lobby & one scene for game. How do we start game by opening another scene? Could you please give me some hints? Thank you
You can enable Scene Management on the NetworkManager, then if you change scenes on the Server it will automatically change them on the Clients I've got a video covering that topic coming out next week, doing a deep dive on Galactic Kittens, and I'm currently working on my upcoming free multiplayer course where I will also cover that.
Is there a way you could show more of the code towards the end of the video? I’m trying to to make relay work with netcode and lobbies but I believe I’m missing some of the pieces because I am getting an error that says "Argument 2: cannot convert from 'System.EventArgs' to 'LobbyManager.LobbyEventArgs'" I believe I declared OnGameStarted because I didnt see how you declared it so I just guessed.
Sounds like you defined your event as using a different type than EventArgs, I just made a regular EventHandler event unitycodemonkey.com/video.php?v=OuZrhykVytg That event isn't doing anything special, it just hides the Lobby UI, nothing else The connection is created on the JoinRelay(); function
I have an error, the log says "Shutdown" and then "Shutdown internal" do you know why this happens? It also says you must call SetRelayServerData() at least once before calling StartRelayServer.
@@CodeMonkeyUnity I see, but relay still wont work. I got this error when using relay, the console says the following: "Unity.Services.Relay.RelayServiceException: Forbidden: inactive or inexistent project ---> Unity.Services.Relay.Http.HttpException`1[Unity.Services.Relay.Models.ErrorResponseBody]: (403) HTTP/1.1 403 Forbidden" Do you know what this means and how to fix it?
What do you mean "start" the game? Go from Lobby to GameScene? You synchronize a message through Lobby, then start the Netcode for Game Objects connection and load the scene. Check out how I did it in my free MP course ruclips.net/video/7glCsF9fv3s/видео.html
Hey! i finished the lobby tut, its awesome! but i have 1 issue with the relay package (i tried to import it to my project several times, and do it on a new project, and several versions of it) i keep getting this error: Burst internal compiler error: System.Exception: Error while generating hash for method references. what should i do?
That's odd, what exactly is throwing that error? It happens when you import the Relay package onto your project? Maybe try uninstalling and reinstalling the Burst package
@@CodeMonkeyUnity Thank you for the fast respond! I really appreciate it! I don't know what happened but it seems to work now, I just opened the project after a day, and again tried to reinstall, and this time I got no error
I have followed all three videos as I am trying to create a multiplayer game. All videos were great individually and together. However, I'm having a tough time connecting everything so the lobby UI --> Multiplayer Relay -->Joining the actual game with Netcode stuff. Is there somewhere you can include how to connect everything to have this sequence? I'd like to wrap all of this into the main menu for my game. Thanks so much for all the content and help! Looking forward to your next projects and guides!
The final demo in this video has everything connected, you can download the project files for the Lobby video and then follow the few changes I made for supporting relay at 18:40 It's really just passing the relay code through the lobby data and using that to start the connection on all clients
@@CodeMonkeyUnity I believe I made all the connections I need but am still receiving this error: CS0117: 'object' does not contain a definition for 'JoinRelay' and no accessible extension method 'JoinRelay' accepting a first argument of type 'object' could be found. I have the same error for 'CreateRelay' as well. These are from 19:27 and 20:06
@@RyanShappa Looks like you're trying to call that function on an "object" which is the default C# object and nothing related to Relay That function is not a built-in function, it's what I wrote at 13:20
@@CodeMonkeyUnity how can I fix it? I noticed at 20:09 you had changed the function to 'public async Task CreateRelay' which returns the joinCode or null. And for the 20:05 'HandleLobbyPolling' function the joinRelay function from TestRelay is not being passed.
@CodeMonkey Something I can't seem to find a lot of information about is saving data for a multiplayer game. In this example, how could I save player position data for all of the players that joined my lobby and played with me?
You would save it exactly the same way as saving in singleplayer. Cycle through all the players and save their data. The only thing extra you need is some sort of identifier so that when you load the game again you can apply the saved data to the correct players
How so? All the Lobby code was built in the lobby video, you can even download the project files I showed all the differences from the Lobby video at 19:22
@@CodeMonkeyUnity On LobbyManager: in CreateLobby() = in data KEY_START_GAME(" The name "KEY_START_GAME" does not exist in the current context") in HandleLobbyPolling() = if (!IsLobbyHost()) TestRelay.Instance.("Test Relay , does not contain a definiton for Instance") onGameStarted? ("The name onGameStarted does not exist in the current context") in the StartGame() at the await TestRelay.Instance.CreateRelay(); ("does not contain definiton of Instance")
Great video as awlays, but there is something I don't understand, using a Relay Server is a host - client connection? So I understand you don't have control on the server? You can't do server - client games with this?
If you have a dedicated server you don't need Relay, you just connect the clients directly to the dedicated server. Relay is useful if you don't have a dedicated server and you need some way to connect 2 clients together that may be behind firewalls, the Relay helps establish a connection through that.
It's a reachable server on the internet that acts as the intermediary between players who might be behind firewalls or NAT. Everyone connects to that server and the server sends the data back and forth
Thank you for the amazing tutorial, you have been such a great help. Do you know why, when I start my game, it says that 'the player is already signing in'? I have copied exactly what you wrote in your Start method
Thanks for this. I did notice that Netcode for Game Objects is seemingly incompatible with WebGL (got a warning in my editor), but was wondering if Relay or Lobby can be used on top of Netcode to work with WebGL?
The limitation is on the Unity Transport layer, so if you swap that out for something that supports WebGL then yes all the other systems should work well on top of it. I believe they are currently working on Transport 2.0 which should support WebGL but not sure what is the current status on that.
Thank you so much for the tutorial! I don't have an account to check your project, I don't know if it's free. Do you also poll for updates in the host lobby (UI)? Because the host, also needs to wait for joining players right?
Hey, I must say that this tutorial is fantastic. My problem is that im doing a vr game and when I click host the vr player works perfectly but when a player joins the game session all the controllers just stop working and any player can move around or move the camera. I have the same set up as the tutorial. Thx for the help
When I create a lobby I get this error "Unity.Services.Lobbies.LobbyServiceException: request failed validation data in body should be at least 0 chars long" . I have just watched the video and put the KEY_START_GAME variable in the lobby.
All the functions would be exactly the same. If you wanted to make like a playable Lobby then the only difference would be to connect to Netcode for Game Objects right away when joining the Lobby and use that for realtime data.
@@CodeMonkeyUnity ok I'll have to give this approach a try. I downloaded the demo that unity put out and there's so much code that is UI dependant which makes it hard to strip out .
Not sure what you mean, this is using netcode and lobby. If you want to see it as part of a complete project I used all 3 in my multiplayer course ruclips.net/video/7glCsF9fv3s/видео.html
@@CodeMonkeyUnity Thank you so much! What I meant was I tried to skip the relay part, but now I managed to do it with relay and it worked like a charm! ❤
Hi man, I'm getting this error and I'm not sure how to fix it: Unity.Services.Relay.RelayServiceException: Bad Request: invalid request schema or decoding failure. I noticed that my PlayerId (printed out in the Start function) is the same every time in every instance that I tested so this might be the issue. I tried running on a VM and with a VPN connected and it was still the same ID. I'm not sure why. I'll test on a friend's pc later. Also, sometimes, the player spawns when the objects haven't been loaded completely (i think?) and it makes them fall through the floor. Is there a way around this? Thank you.
I found out what's wrong. It was the InputField i used. For some reason, it added an invisible white space that cannot be distinguish by eye. It caused me so many problems. Debug.log and vs code debug mode don't display it at all. Add this to replace the white space: joinCode = joinCode.Replace("\u200B", ""); I'm still looking for the best way to make the player spawns staying on the ground.
Since you have connections with unity, Why isn't p2p (relay) free to use forever? Epic/Steam/Discord offer it like this and should be standard. Would get people familiar with unity multiplayer overall and more people would use the rest of their services. They always mention "great pricing" but it's literally the only thing that holds me back from trying unity networking, even the other price models are crazy.
By the way you can use all the tools independently. So if you're making a Steam game you can definitely use Netcode for Game Objects and Unity Lobby combined with Steam Relay. I don't have any special insight into how Unity decides their pricing but I would guess the reason is simply cost. Steam already has a huge datacenter network for sending all the game download data, adding support for Relay in the datacenters they already own probably doesn't cost them much. Epic has Fortnite which is an infinite money printer and again also already has datacenters all over the world so adding Relay support doesn't cost them much. Unity on the other hand doesn't have any massive datacenters or private internet connections all over the place. I assume what they're using in the background is probably Google Cloud which they have to pay themselves. I've looked at the stats of my own games, and they very rarely crossed the 50 CCU mark. So if those games were mainly multiplayer and I used Unity Relay I would have had to pay something like $100 out of $100,000+ revenue, that seems like a great deal to me.
@@CodeMonkeyUnity I want to clarify the word "crazy" you are right that it's still worth using it, I just meant compared to other services I use, it's always higher price so why would I switch? I do want my untiy games to be using unity services but if even the price isn't worth why would I use their services that tend to not last anyways. I love unity engine, I do but the multiplayer part still feels so amature. I do disagree with you that unity couldn't pull this off and make it free money wise but at the same time unity licence is super fair. I'm not trying to jab unity because once again overall it's fair I just want them to offer services that are either equal or better to others out there so more people switch over. I would swap in a heartbeat :)
Please help me understand a doubt that I have. If the players use Relay by hosting the game on their own computer (similar to Risk of Rain 2) where one of the players is the host and the remaining 3 are joining, would that be included in the "pricing" system, or would the players be able to connect for free?
If you're connecting directly then you're not using the Relay at all, but in order to connect directly the host needs to enable port forwarding or some kind of NAT punchtrhough method.
Hey CodeMonkey, in the last minutes of the video i dont understand quite well the pricing for CCU, if there a 3 lobbies (wich means 3 relays) with 50 player in each of them will i pay extras or it will remain free?
I am watching this a while after it came out. Good tutorial but I have a question, can players connect if they are connected to the same internet? I was able to run multiple builds on my PC and everything ran perfectly, however when I try to use my laptop to connect which uses the same internet, they couldn't connect. I haven't tried connecting to a remote build yet but I am wondering how I could connect on the same internet.
Hmm I haven't tested that out specifically but it should work. Although usually if you're doing local multiplayer you don't need relay at all since locally there are no issues with NAT/Firewall What is the exact error? Maybe it doesn't work because 2 clients are trying to listen on the same port, if that's the case maybe try using different ports.
Thanks for the good tutorial. I got two questions: 1. Will the relay server stay online if no players are connected? 2. Is it possible to "reconnect" via the join code or is there another way? Thanks a lot!
If there are no connections after 10s the relay connection is closed. If that happens and you want to "reconnect" you would just request another allocation and join.
❤ Watch my FREE Complete Multiplayer Course ruclips.net/video/7glCsF9fv3s/видео.html
✅ Learn more about Relay and UGS on.unity.com/3tQZLLW
📝 Relay Docs on.unity.com/3OjXL8z
🔴 RELATED VIDEOS 🔴
COMPLETE Unity Multiplayer Tutorial (Netcode for Game Objects) ruclips.net/video/3yuBOB3VrCk/видео.html
Join your Players in MULTIPLAYER with Lobby! (Unity Gaming Services) ruclips.net/video/-KDlEBfCBiU/видео.html
What is Unity Gaming Services? ruclips.net/video/JwClCc2_zC8/видео.html
EASY Console! Run any Command! (Add Cheats, Set Gravity, Spawn Enemies Quantum Console Asset Review) ruclips.net/video/bOf6CjpuSFs/видео.html
🌍 Get my Complete Courses! ✅ unitycodemonkey.com/courses
👍 Learn to make awesome games step-by-step from start to finish.
🎮 Wishlist my Next Steam game! cmonkey.co/totalworldliberation
Hope to see a solution when the host disconnected in the middle of the game and a member in the game pick up the game as a host.
do you have a video for inviting player to your library from steam ?
I think the relay connection with NGO part is outdated, as I am getting errors of some of these types not existing
Just finished all 3 videos on this and just have to say thanks for the in depth guides. Got my basic multiplayer up and running!
I'm glad the videos helped you! Thanks!
Missing bits:
LobbyUI Script:
[SerializeField] private Button startGameButton;
LobbyManager Script:
public const string KEY_START_GAME = "Start";
public event EventHandler OnGameStarted
TestRelay Script:
using System.Threading.Tasks;
public static TestRelay Instance { get; private set; }
private void Awake() {
Instance = this;
}
Thank you! I was wondering why I got the "No instance" error whenever I tried to open my relay
Imagine that I'm watching your tutorials then directly testing and trying, and when I tried to make a starting game function I didn't find any way, and I lived a week of hard researching, until I thought "let's just go and see Code Monkey's next video, maybe it has something helpful", then when I heard in 0:57 "the host starts the game" my hopes and dreams started floating in my mind. Thank you!!!!
I cannot stress enough how helpful this would've been about half a year ago for me. I tried to make an online lobby system using only NGO, but had troubles with connecting and even had to turn off my Windows Defender for it. Seeing this tutorial makes me really happy, and I'll definitely be saving this one for the future.
This is the video I was waiting for! I needed a vision for how these services fit together, and the end of this video did that for me. One huge thing for me that would have been helpful that I'm just now learning is when to implement these different packages in your game development cycle. The whole time I was starting to implement Netcode I was worried that I'd have to redo all of my work as soon as I wanted to add Relay and Lobby, since I didn't understand them. What I learned from these 3 tools was:
1. Implement Netcode from the beginning, the longer you wait the bigger headache it is to implement.
2. Lobby and Relay can be implemented relatively whenever, and implementing them later in the project doesn't have huge cons. (The only real con is if you already had a lobby screen and you needed to rewire it to use Lobby)
Yup that's definitely what I would do. If the game is intended to be primarily multiplayer then definitely get Netcode implemented as quickly as possible, the other tools can wait.
I'm glad the video heped you, thanks!
Lessgoo! I’ve been waiting for this! Finally I can take my multiplayer game online! Thank you (also first)
I was just thinking about making a multiplayer game and I remembered that Unity just made multiplayer easier. This is perfect timing!
A good use-case fort starting a relay already whilst in the lobby is something like Among us where in the lobby you can already run around and see each other :)
Yup! Having a simple fun scene for the players to test out the controls is a great use case
Let's go back to back multiplayer tutorials
from where to start this whole tutorial step by step
@@TheJangoo if i remember correctly there is a 1 hr video regarding netcode for game object on his channel. This video was after that.
Also there is a 6 hrs tutorial on his channel as well.
@@durvesh007 got it thanks 👍
CodeMonkey!, first of all, I have to admit strongly that you are really really amazing. You have saved and helped me many times and this is the first time I comment on your videos. There's no downside to your videos. Your content is really nice, clean, short, useful, without any extra time-consuming words. and besides, you really code so professionally. and you cover all the details. your videos are really well-designed.
This playlist is really unique and astonishing. God save the CodeMonkey!
Thanks for the kind words! I'm glad my videos have helped you! Thanks!
@@CodeMonkeyUnity Just one topic I haven't got. you just used lobby and relay and netcode gameobject to develop a multiplayer online game.
the question of mine is, then what are Game Server Hosting (Multiplay) & Matchmaker for??! when do we have to use them while everything is done through relay and netcode?
This video is a godsend! I've been racking my brain trying to figure out how to set up relay for months until I finally found this video and now it seems so easy! Thanks CM!
I'm glad the video helped you! Thanks!
Appreciate the video, great quality as always! I'm making my first venture into multiplayer and you've demystified quite a bit
This Unity tool is amazing, I'm really happy it exists.🔥🎮✌🏻
Thank you for the great Tutorial 👍🏻
Very cool. Thanks, as always, for the great information! It was a bit confusing there at the end when you tied Relay and Lobby together, but only because you did it with your downloadable "project example" and not with the TestLobby code you showed us how to create directly in the last tutorial. I do have the demo, however, and was already planning to take it apart & dissect it, so it should be fairly easy to implement once I've wrapped my head around the changes & additions you've made to the code there. I'm sure I'll be back to reference the end of the video again here very soon, so I'll just leave it open. Have a terrific day & thanks again!
Thank you so much for these awesome UGS tutorials!
You said in the video there would be timestamps, but I see none :(
Thank you for the 3 tutorials i watched now
At 8:52 I am getting this error: Unity.Services.Relay.RelayServiceException: You are not signed in to the Authentication Service. Please sign in.
Please help
You need to initialize and sign in to Unity Authentication unitycodemonkey.com/video.php?v=1KSKRaacdKE
3:10 I can't find multiplayer under the dashboard.
Thank you for your great videos! I have a problem at 8:52. I get the error: Failed to connect to player IP: CreateRelay:55000-55495,35000,4600,4600. Socket: Connection Failed, Error: A connection could not be established because the target machine refused the connection. could anybody help me?
Is that the full error? That's odd, at that point it should only be trying to contact the relay server to create it, it's not yet connecting anything like the NetworkManager.
I would say make sure your Unity isn't being blocked by your firewall but if you can initialize the services and sign in then it's not being blocked.
@@CodeMonkeyUnity I am facing this issue sometimes.
I would also really, really like a video on how to set up a fresh game with a dedicated server. I've been trying to set it up myself, but it seems like a lot of steps are missing, maybe. I went through the example Battle Royale game, but it didn't answer all of my questions. I can't even get the server to recognize my command line arguments in the launch parameters.
Thanks for the tutorials as always.
Yup researching Multiplay/Game Server Hosting is something I'd like to do, I'm currently busy with other projects but hopefully next month
I have been able to make the game run but when I press the start game button, I get an error that refers to this line : "string relayCode = await RelayManager.Instance.CreateRelay();" And the error is a NullReferenceException which causes the game to not start. I believe I am missing something when it comes to the RelayManager script or in your case the TestRelay.
Simply sounds like you don't have any object with the RelayManager script, or you're not assigning the singleton Instance
Could you also explain what imports you need to use for your code for your next video? It's a bit tedious having to pause the video at the right moment just to see what library I need to import in your IDE's auto-complete box.
Not sure what you mean by that, the only thing you need is the Relay package which I covered in the video. Are you talking about the "usings"? I paused for a while every time the IDE was automatically adding a new one
@@CodeMonkeyUnity yeah, the usings, like that moment in 12:11, the unity transport comes from another using that your IDE automatically set up. Your videos are great, it's just that I came from other "tutorials" (which are really just hand-holding not explaining anything) that tell you to use something that hasn't been implemented yet, and later in the video, they implement it, and it took me a while to realize it was just a 'using' and not something you were going to implement later lol.
And yeah, this is more of my fault I missed it, so you don't really need to listen to me lol.
@@Quantiflyer life saver. thanks
I have git hub desktop installed, but i cannot install the git package in my unity, it tells me unable to be found :(
i dont understand the 17:13 how can i connect to another pc on this project ? using vpn ? but how ? pls help
I used a VPN just to demonstrate how it can connect to an external IP and not just another PC on my local network. You just use Relay and it handles making that connection without worrying about firewalls or NAT
Hugo is the best!!
I am at about 16:20 and I keep getting errors saying " The type or namespace 'RelayServerData' could not be found" There is also another error saying that the name 'allocation' does not exist in current context.
Please help, thanks😅.
Do you have 'using Unity.Networking.Transport.Relay;'?
@@CodeMonkeyUnity Nope, I just added it and the server relay data errors went away but the allocation one is still there.
nevermind, i got it. I was using 'allocation' variable instead of 'joinAllocation' for the join relay.
Thanks so much for the quick response!
I have Netcode 1.2.0 and Transport 1.3.0 but the RelayServerData constructor as you show in the tutorial doesn't exist here. I'm using the DLTS endpoint approach *var dtlsEndpoint = a.ServerEndpoints.Find(e => e.ConnectionType == "dtls"); * It works ok but it doesn't work around my firewall issues :(
same here, did you solve it?
also these docs unity provide won't help at all
so its not just me, how did you handle it
add using Unity.Netcode.Transports.UTP;
This worked for me:
using Unity.Netcode;
using Unity.Netcode.Transports.UTP;
using Unity.Networking.Transport.Relay;
Sweet!!! You da best Code Monkey!
You got yourself a new subscriber.
Thanks a lot for these amazing tutorials on multiplayer handling, Code Monkey!
Cheers from one Portuguese to another (margem sul here, I'm guessing we're kind of neighbors)
I'm glad the videos have helped you! Obrigado!
6:05
what did you do to get that menu to show up? when i click play I don't see that so i'm not sure if my code is working.
That's the Quantum console ruclips.net/video/bOf6CjpuSFs/видео.html
Or you can just read the normal unity console
@@CodeMonkeyUnity since the unity console won’t come up I’ll download and watch the video on using this instead
For anyone having trouble finding it UnityTransport is in the following namespace: Unity.Netcode.Transports.UTP
ty
This video is really so helpful!
Thanks a lot!
Hi, first wonderful video, but I've probably watched it over 10 times now and still have a list full with errors when I tried to bring lobby and relay together. Would it be possible for you, to publish the Unity Project or to copy the finished script (as it was at the end of the video) TestRelay and LobbyManager as an answer so that I can compare my script with those scripts?
I second this!
What errors? The Lobby video has the downloadable project files, I didn't include the ones for this video because the Relay is just a dozen lines of code which are visible in the video
@@CodeMonkeyUnity Thanks for replying, I think I did everything like in the video but got a few errors. All errors are in the LobbyManager script:
1. "TestRelay" does not contain a definition for instance
2.again the same error message
3. Argument "2": Unable to convert System.EventArgs to LobbyManager.LobbyEventArgs.
4. No argument was specified that matches the formal parameter "value" of "Dictionary. Add(string, DataObject)".
I am new to Unity so it would be great if you could help me.
@@funkfollow9754 It sounds like you really need to learn C# basics before you go any further unitycodemonkey.com/video.php?v=IFayQioG71A
If you're a Unity beginner I would highly recommend you start with a simple singleplayer project. Making multiplayer games makes everything 10x more difficult
08:03 Code Monkey ~ "it really is that simple". Haha, not for me xD. I finished the Tutorial and its just amazing. I didnt use the Add on for the Console (40$), but i just made a Function that gets called by a Input GUI call and it works fine, for writing in the code and for creating i just made the button, when pressed to call the function.
Can you tell me how you did that?
@@VoiceOfTheFutureYU Its hard to explain. But i will try. You have to say when the button is pressed you call the function, in this case "start the server". So you dont have to write commands, even tho you could do one console from scratch its not that hard. Learn how to use the GUI and you will see, its very easy.
Thank you! Very useful!
Wow this is phenomenal
can you compare PUN2 and this...thank you...
This. Seems like PUN is doing all this for you already automatically
I made my entire game using Netcode for GameObjects / Lobby / Relay, and now I get +350 ping or RTT.
Even with the boss game demo, my ping was +350.
It's caused by my location.
So, I tested Photon and my ping was 80.
What alternatives do I have?
Can I use Photon servers instead of Relay?
How do I integrate that? Or what's an alternative to Relay?
Please make a tutorial about that if it's possible.
That ping will depend on the relay server location, sounds like the closes relay is quite far from you
But that ping, while it looks high, it is perfectly acceptable for the kinds of games that NGO was made for, co-op casual games, it's only an issue for hyper competitive super fast paced shooters
The question of ping is not really related to the underlying toolstack you use. Photon or NGO will be mostly the same.
What matters is you server architecture. Fastest is Dedicated server (close to you), then you have peer 2 peer, and last you have Relay.
in the lobby manager i keep geting a compiler error for 'TestRelay' does not contain a definition for 'Instance' does anyone know how to fix this?
Did you define an Instance field in it? Maybe you named it 'instance' instead
@@CodeMonkeyUnity i fixed it bc of a comment saying the bits of code you missed
Hello! I am learning to write server side code using c# sockets (TcpListener UdpClient etc). My problem is that I only know so far that the server should start working on the given ip and port. I don't want to use ready-made solutions (Mirror Photon etc) because I want to learn how to write code from scratch myself.
I want to create a p2p logic game and I noticed at 12:42 that Relay returns ip and port. Question: Can I use these ip and port to start listening based on them and only then, when other players connect via Relay, will they connect to this ip and port? Thanks in advance for your reply
Привет! Я учусь писать серверный код используя c# sockets (TcpListener UdpClient etc). Моя проблема в том, что я пока только знаю что сервер должен начинать работу на заданном ip и port. Я не хочу использовать готовые решения (Mirror Photon etc), потому что хочу научиться писать код с нуля сам. Я хочу создать игру по логике p2p и я заметил на 12:42 что Relay возвращает ip и port. Вопрос: Могу ли я использовать эти ip и port, чтобы на их основе запускать прослушивание и уже потом, когда другие игроки подключатся через Relay они будут подключаться к этому ip и port? Заранее спасибо за ответ
At 17:55 you said that you set the name to get a new player ID. I might have missed something but is it possible to have different authentication IDs on the same computer? This would help a lot for testing. Thanks
Yes, you call SetProfile when initializing the services and when using different profiles you get different auth id allowing you to have multiple builds running
Could you make host migration with netcode for gameobject?(i don't know how to build at all)
When joining a relay allocation that already has the maximum members connected, JoinAllocationAsync does not throw an exception. Is there some other way to check whether joining the relay is possible?
Is there a way I could take a look at the demo project files shown in the video?
The only "complex" part is the lobby which you can download the project files from the lobby video
Alright thanks, I realize how simple it is to integrate relay now.
Really like you videos! keep it up. Did you provide the latest project on this video on your website?
The Lobby has downloadable project files unitycodemonkey.com/video.php?v=-KDlEBfCBiU
I didn't make them for the Relay since the code is really simple, you can watch the code in the video and implement it
If you want to see it as part of a complete game I also used Lobby and Relay in my Free Multiplayer Course unitycodemonkey.com/kitchenchaosmultiplayercourse.php
@@CodeMonkeyUnity Thanks man. Really appreciate it!
Great video as usual, I am very interested to see how would a dialogue system work with the open ai gpt-3 system, will you ever have the chance to cover that as I see there isn't any much explanation on this subject as it is relatively new so it would be nice fo you to explain it and I am sure a lot of people would love it. As always great job and keep up the good work
A game mechanic where you would talk to an AI? That could be interesting
Thank you for the great content!
This looks great! I have a problem about this;
When I host from editor, and connect from windows build, everything works great. But if I open 2 builds, and host from one and connect from other, client seem can't connect to the game.
If I host from windows build, and connect from editor, this also works.
So the problem is when I open 2 windows build and create & connect.
Just amazing! Awesome tutorial, I have learned a lot.
I was wondering if could could make a video that explains how to utilize the private lobby functionality, because currently, setting the lobby to private, there's now way to join it haha.
Also, an example of how to make a screen with a "quit" button upon pressing escape would be great (not talking about the UI, but rather what do we need to cleanup when a player exists/lobby is destroyed upon host exit)
Another suggestion is a loading screen while the relay is loading or something. But I know that's already too much lol... these are just suggestions!
If you set the Lobby as private you join it with the Lobby code
You don't need to handle clean up manually, if all players leave the Lobby Unity will automatically destroy it
missing some code when adding lobby and relay together from LobbyManager...
What are you missing? The Relay additions are just a handful of lines which are all shown in the video
@@CodeMonkeyUnity On LobbyManager:
in CreateLobby() = in data KEY_START_GAME(" The name "KEY_START_GAME" does not exist in the current context")
in HandleLobbyPolling() = if (!IsLobbyHost()) TestRelay.Instance.("Test Relay , does not contain a definiton for Instance")
onGameStarted? ("The name onGameStarted does not exist in the current context")
in the StartGame() at the await TestRelay.Instance.CreateRelay(); ("does not contain definiton of Instance")
@@Diskokeisari how did you solve this problem?
@@nemanjasekulic711 public const string Key_Start_Game = "Start" , Key_Game_Mode = "Survival"; in the main script
@@nemanjasekulic711 public event EventHandler OnJoinedLobby;
add this for all missing ones
Nn the unity transport there is field for Adress and Port. What am i supposed to put there. Does it even matter? currently i have on localhost ip but will that work if i send the build to a friend?
How would I go about making the player update older builds as I release updates. Would the game break if players from different builds joined the same server?
You could include the version in the public Lobby data and only let players join if they have the same version
Tried the built in relay sample after having issues switching over to it on something else, and it gave the same error when trying to join from a second client "Join code not found". Then tested the second example, it states allows testing from multiple clients, which occasionally gives the same error but for the most part works. Had to watch you give a paid for tutorial to see it is because a connection must be established within an arbitrary time frame. Still cant get it to run properly in my initial project, yet other network transports work without any issues.
can you make a course on this for multiplayer only
How do you handle disconnecting from the sever as from the client side? like what if the host decides to quit out?
I'm having troubles
Please make a video with matchmaker
Thank you for your tutorial.
One more question! If we have one scene for lobby & one scene for game. How do we start game by opening another scene? Could you please give me some hints? Thank you
You can enable Scene Management on the NetworkManager, then if you change scenes on the Server it will automatically change them on the Clients
I've got a video covering that topic coming out next week, doing a deep dive on Galactic Kittens, and I'm currently working on my upcoming free multiplayer course where I will also cover that.
Is there a way you could show more of the code towards the end of the video? I’m trying to to make relay work with netcode and lobbies but I believe I’m missing some of the pieces because I am getting an error that says "Argument 2: cannot convert from 'System.EventArgs' to 'LobbyManager.LobbyEventArgs'" I believe I declared OnGameStarted because I didnt see how you declared it so I just guessed.
Sounds like you defined your event as using a different type than EventArgs, I just made a regular EventHandler event unitycodemonkey.com/video.php?v=OuZrhykVytg
That event isn't doing anything special, it just hides the Lobby UI, nothing else
The connection is created on the JoinRelay(); function
@@CodeMonkeyUnity you won’t see this probably but thanks so much for responding to your comments, it’s amazing.
How to make it automatically start with any random lobby
I have an error, the log says "Shutdown" and then "Shutdown internal" do you know why this happens? It also says you must call SetRelayServerData() at least once before calling StartRelayServer.
It usually says that when you stop playing and it closes the server
@@CodeMonkeyUnity I see, but relay still wont work.
I got this error when using relay, the console says the following:
"Unity.Services.Relay.RelayServiceException: Forbidden: inactive or inexistent project ---> Unity.Services.Relay.Http.HttpException`1[Unity.Services.Relay.Models.ErrorResponseBody]: (403) HTTP/1.1 403 Forbidden"
Do you know what this means and how to fix it?
nevermind i fixed it, i just had to put relay on and off 100 times :)
@@ProdbyMaxim ? I'm having the same issue?
@@thejuicedorange9317 just put relay on and off 100 times in the unity website
But , you gave the files of the lobby on your older video , but it havn't all the code to Start the game in it ??
What do you mean "start" the game? Go from Lobby to GameScene? You synchronize a message through Lobby, then start the Netcode for Game Objects connection and load the scene.
Check out how I did it in my free MP course ruclips.net/video/7glCsF9fv3s/видео.html
do you have a video for inviting player to your library from steam ?
or recommendation ?
You need to look into the Steam API for how to do that
How does this have under 1k likes you are amazing!
I'm glad you liked the video! Thanks!
@@CodeMonkeyUnity And im glad your doing these vids! Finally managed to setup relay for my little game prototype all thanks to you :)
this is awesome!
thanks a lot for your great tutorials, i wish we have one for host migration
Does Relay require a Internet Connection or would it also work offline with a LAN only scenario?
The Relay is a Unity server on the Internet so yes it requires a connection, for LAN you would connect directly rather than use Relay
Hey!
i finished the lobby tut, its awesome!
but i have 1 issue with the relay package (i tried to import it to my project several times, and do it on a new project, and several versions of it)
i keep getting this error: Burst internal compiler error: System.Exception: Error while generating hash for method references.
what should i do?
That's odd, what exactly is throwing that error? It happens when you import the Relay package onto your project?
Maybe try uninstalling and reinstalling the Burst package
@@CodeMonkeyUnity Thank you for the fast respond!
I really appreciate it!
I don't know what happened but it seems to work now, I just opened the project after a day, and again tried to reinstall, and this time I got no error
I have followed all three videos as I am trying to create a multiplayer game. All videos were great individually and together. However, I'm having a tough time connecting everything so the lobby UI --> Multiplayer Relay -->Joining the actual game with Netcode stuff.
Is there somewhere you can include how to connect everything to have this sequence? I'd like to wrap all of this into the main menu for my game. Thanks so much for all the content and help! Looking forward to your next projects and guides!
The final demo in this video has everything connected, you can download the project files for the Lobby video and then follow the few changes I made for supporting relay at 18:40
It's really just passing the relay code through the lobby data and using that to start the connection on all clients
@@CodeMonkeyUnity I believe I made all the connections I need but am still receiving this error:
CS0117: 'object' does not contain a definition for 'JoinRelay' and no accessible extension method 'JoinRelay' accepting a first argument of type 'object' could be found.
I have the same error for 'CreateRelay' as well.
These are from 19:27 and 20:06
@@RyanShappa Looks like you're trying to call that function on an "object" which is the default C# object and nothing related to Relay
That function is not a built-in function, it's what I wrote at 13:20
@@CodeMonkeyUnity how can I fix it?
I noticed at 20:09 you had changed the function to 'public async Task CreateRelay' which returns the joinCode or null. And for the 20:05 'HandleLobbyPolling' function the joinRelay function from TestRelay is not being passed.
@CodeMonkey Something I can't seem to find a lot of information about is saving data for a multiplayer game. In this example, how could I save player position data for all of the players that joined my lobby and played with me?
You would save it exactly the same way as saving in singleplayer. Cycle through all the players and save their data. The only thing extra you need is some sort of identifier so that when you load the game again you can apply the saved data to the correct players
Did someone get it working with this with Lobby? i have trouble because there is code missing that cannot see in the video
How so? All the Lobby code was built in the lobby video, you can even download the project files
I showed all the differences from the Lobby video at 19:22
@@CodeMonkeyUnity On LobbyManager:
in CreateLobby() = in data KEY_START_GAME(" The name "KEY_START_GAME" does not exist in the current context")
in HandleLobbyPolling() = if (!IsLobbyHost()) TestRelay.Instance.("Test Relay , does not contain a definiton for Instance")
onGameStarted? ("The name onGameStarted does not exist in the current context")
in the StartGame() at the await TestRelay.Instance.CreateRelay(); ("does not contain definiton of Instance")
Great video as awlays, but there is something I don't understand, using a Relay Server is a host - client connection? So I understand you don't have control on the server? You can't do server - client games with this?
If you have a dedicated server you don't need Relay, you just connect the clients directly to the dedicated server.
Relay is useful if you don't have a dedicated server and you need some way to connect 2 clients together that may be behind firewalls, the Relay helps establish a connection through that.
So Is Unity Relay a remote server service for hole-punching techinque?
It's a reachable server on the internet that acts as the intermediary between players who might be behind firewalls or NAT. Everyone connects to that server and the server sends the data back and forth
@@CodeMonkeyUnity t acts as the intermediary between players mean it may cost more delay time?
Thank you for the amazing tutorial, you have been such a great help. Do you know why, when I start my game, it says that 'the player is already signing in'? I have copied exactly what you wrote in your Start method
If you run multiple builds on your PC you need to sign them up with different profiles, otherwise they will connect as the same player
Ok so, you would use this method for Steam or not for Steam? The last thing I need to do for my project is connect to Steam for multiplayer.
Hi CodeMonkey, incredible video as always. I was wondering if you are going to show how to use Vivox too.
Yup I'd like to research that one
Thanks for this. I did notice that Netcode for Game Objects is seemingly incompatible with WebGL (got a warning in my editor), but was wondering if Relay or Lobby can be used on top of Netcode to work with WebGL?
The limitation is on the Unity Transport layer, so if you swap that out for something that supports WebGL then yes all the other systems should work well on top of it.
I believe they are currently working on Transport 2.0 which should support WebGL but not sure what is the current status on that.
Will you make a video about the unity CCD with addressables?
I made a free video on Addressables unitycodemonkey.com/video.php?v=C6i_JiRoIfk
Then in that course is another one on Addressables Remote and CCD
@ CodeMonkey I got it working but wondering why I have to enclose the KEY_START_GAME in quotation marks while you're going without?
Sounds like you didn't define that symbol as a string constant, I used the same pattern I used in the Lobby video of using constants for the keys
@@CodeMonkeyUnity Oh lol I've never used const, but I now see why it's being used here after looking it up. Thanks!
Thank you so much for the tutorial! I don't have an account to check your project, I don't know if it's free. Do you also poll for updates in the host lobby (UI)? Because the host, also needs to wait for joining players right?
Hey, I must say that this tutorial is fantastic. My problem is that im doing a vr game and when I click host the vr player works perfectly but when a player joins the game session all the controllers just stop working and any player can move around or move the camera. I have the same set up as the tutorial. Thx for the help
Doesn't sound like it's related to Relay, sounds like it's related to however you are synchronizing data with Netcode for Game Objects
When I create a lobby I get this error "Unity.Services.Lobbies.LobbyServiceException: request failed validation
data in body should be at least 0 chars long" .
I have just watched the video and put the KEY_START_GAME variable in the lobby.
Any advice on how to handle a 3D / interactive lobby opposed to a UI?
All the functions would be exactly the same. If you wanted to make like a playable Lobby then the only difference would be to connect to Netcode for Game Objects right away when joining the Lobby and use that for realtime data.
@@CodeMonkeyUnity ok I'll have to give this approach a try. I downloaded the demo that unity put out and there's so much code that is UI dependant which makes it hard to strip out .
Love this high quality tutoiral with relay!
Is there a video like this but with netcode? Or is it possible to make this with netcode and lobby?
Not sure what you mean, this is using netcode and lobby. If you want to see it as part of a complete project I used all 3 in my multiplayer course ruclips.net/video/7glCsF9fv3s/видео.html
@@CodeMonkeyUnity Thank you so much! What I meant was I tried to skip the relay part, but now I managed to do it with relay and it worked like a charm! ❤
Thank you! ⭐⭐⭐⭐⭐
Hi man, I'm getting this error and I'm not sure how to fix it: Unity.Services.Relay.RelayServiceException: Bad Request: invalid request schema or decoding failure.
I noticed that my PlayerId (printed out in the Start function) is the same every time in every instance that I tested so this might be the issue. I tried running on a VM and with a VPN connected and it was still the same ID. I'm not sure why. I'll test on a friend's pc later.
Also, sometimes, the player spawns when the objects haven't been loaded completely (i think?) and it makes them fall through the floor. Is there a way around this?
Thank you.
I found out what's wrong. It was the InputField i used. For some reason, it added an invisible white space that cannot be distinguish by eye. It caused me so many problems. Debug.log and vs code debug mode don't display it at all.
Add this to replace the white space:
joinCode = joinCode.Replace("\u200B", "");
I'm still looking for the best way to make the player spawns staying on the ground.
Since you have connections with unity, Why isn't p2p (relay) free to use forever? Epic/Steam/Discord offer it like this and should be standard. Would get people familiar with unity multiplayer overall and more people would use the rest of their services. They always mention "great pricing" but it's literally the only thing that holds me back from trying unity networking, even the other price models are crazy.
By the way you can use all the tools independently. So if you're making a Steam game you can definitely use Netcode for Game Objects and Unity Lobby combined with Steam Relay.
I don't have any special insight into how Unity decides their pricing but I would guess the reason is simply cost.
Steam already has a huge datacenter network for sending all the game download data, adding support for Relay in the datacenters they already own probably doesn't cost them much.
Epic has Fortnite which is an infinite money printer and again also already has datacenters all over the world so adding Relay support doesn't cost them much.
Unity on the other hand doesn't have any massive datacenters or private internet connections all over the place. I assume what they're using in the background is probably Google Cloud which they have to pay themselves.
I've looked at the stats of my own games, and they very rarely crossed the 50 CCU mark. So if those games were mainly multiplayer and I used Unity Relay I would have had to pay something like $100 out of $100,000+ revenue, that seems like a great deal to me.
@@CodeMonkeyUnity I want to clarify the word "crazy" you are right that it's still worth using it, I just meant compared to other services I use, it's always higher price so why would I switch? I do want my untiy games to be using unity services but if even the price isn't worth why would I use their services that tend to not last anyways. I love unity engine, I do but the multiplayer part still feels so amature. I do disagree with you that unity couldn't pull this off and make it free money wise but at the same time unity licence is super fair. I'm not trying to jab unity because once again overall it's fair I just want them to offer services that are either equal or better to others out there so more people switch over. I would swap in a heartbeat :)
Thank you!
The IsLobbyHost & IsPlayerInLobby & GetJoinedLobby functions are in another video,
at timestamp 47min 30sec ruclips.net/video/-KDlEBfCBiU/видео.html
thank u sm
Please help me understand a doubt that I have. If the players use Relay by hosting the game on their own computer (similar to Risk of Rain 2) where one of the players is the host and the remaining 3 are joining, would that be included in the "pricing" system, or would the players be able to connect for free?
If you're connecting directly then you're not using the Relay at all, but in order to connect directly the host needs to enable port forwarding or some kind of NAT punchtrhough method.
I'm really desperate for multiplayer matchmaker.
Please can you make a video on that.
Yup, it's on my list to cover, hopefully next month
Hey CodeMonkey, in the last minutes of the video i dont understand quite well the pricing for CCU, if there a 3 lobbies (wich means 3 relays) with 50 player in each of them will i pay extras or it will remain free?
What counts is the total, what you are describing are 150 CCUs so yes that is past the free tier, that would cost you $16
@@CodeMonkeyUnity ok perfect thanks you!
I am watching this a while after it came out. Good tutorial but I have a question, can players connect if they are connected to the same internet? I was able to run multiple builds on my PC and everything ran perfectly, however when I try to use my laptop to connect which uses the same internet, they couldn't connect. I haven't tried connecting to a remote build yet but I am wondering how I could connect on the same internet.
Hmm I haven't tested that out specifically but it should work. Although usually if you're doing local multiplayer you don't need relay at all since locally there are no issues with NAT/Firewall
What is the exact error? Maybe it doesn't work because 2 clients are trying to listen on the same port, if that's the case maybe try using different ports.
I downloaded a VPN for my laptop and everything seemed to run perfectly, I guess i'll need an option to connect by LAN aswell.@@CodeMonkeyUnity
Thanks for the good tutorial. I got two questions:
1. Will the relay server stay online if no players are connected?
2. Is it possible to "reconnect" via the join code or is there another way?
Thanks a lot!
If there are no connections after 10s the relay connection is closed. If that happens and you want to "reconnect" you would just request another allocation and join.
@@CodeMonkeyUnity Thank you! I sent you a mail, if you'd like to help me out. Best, Tony
THANK YOU!
Is a CCU while they are signing in or the entire time they are playing the game?
It's concurrent, so while they are connected to the Relay
Photon or Netcode what should I use?