How to use Unity Relay, Multiplayer through FIREWALL! (Unity Gaming Services)
Вставка
- Опубліковано 1 гру 2022
- ❤ Watch my FREE Complete Multiplayer Course • Learn Unity Multiplaye...
✅ Learn more about Relay and UGS on.unity.com/3tQZLLW
📝 Relay Docs on.unity.com/3OjXL8z
🌍 Get my Complete Courses! ✅ unitycodemonkey.com/courses
👍 Learn to make awesome games step-by-step from start to finish.
👇 Click on Show More
🎮 Get my Steam Games unitycodemonkey.com/gamebundle
🎮 Wishlist my Next Steam game! cmonkey.co/totalworldliberation
Unity Multiplayer PUNCH through FIREWALLS with Relay!
Multiplayer through FIREWALL with Relay! (Unity Gaming Services)
🔴 RELATED VIDEOS 🔴
COMPLETE Unity Multiplayer Tutorial (Netcode for Game Objects) • COMPLETE Unity Multipl...
Join your Players in MULTIPLAYER with Lobby! (Unity Gaming Services) • Making a MULTIPLAYER G...
What is Unity Gaming Services? • Free Unity Multiplayer...
EASY Console! Run any Command! (Add Cheats, Set Gravity, Spawn Enemies Quantum Console Asset Review) • EASY Console! Run any ...
💬 Let's learn how to use Unity Relay which is a tool for helping you connect players even while behind Firewalls. So no more issues with Port Forwarding, handling NAT or anything.
The Unity Relay is accessible from the internet so all players connect to it and everyone can play together.
This is pretty easy to implement so in this video let's combine this with the 2 other Unity Gaming Services tools, Netcode for Game Objects and Lobby.
With all 3 you can create a Lobby for your players to find each other, use Relay to connect them together, and use Netcode for Game Objects to handle the multiplayer logic.
Thanks to all these tools making Multiplayer games is now easier than ever.
📝 Some Links are Affiliate links which means it costs the same to you and I get a nice commission.
🌍 Get Code Monkey on Steam!
👍 Interactive Tutorials, Complete Games and More!
✅ store.steampowered.com/app/12...
If you have any questions post them in the comments and I'll do my best to answer them.
🔔 Subscribe for more Unity Tutorials / @codemonkeyunity
See you next time!
📍 Support on Patreon / unitycodemonkey
🎮 Grab the Game Bundle at unitycodemonkey.com/gameBundl...
📝 Get the Code Monkey Utilities at unitycodemonkey.com/utils.php
#unitytutorial #unity3d #gamedev
--------------------------------------------------------------------
Hello and Welcome!
I'm your Code Monkey and here you will learn everything about Game Development in Unity using C#.
I've been developing games for several years with 8 published games on Steam and now I'm sharing my knowledge to help you on your own game development journey.
I do Unity Tutorials on just about every topic, Unity Tutorials for Beginners and Unity Tutorials for Advanced users.
You can see my games at www.endlessloopstudios.com
--------------------------------------------------------------------
- Other great Unity channels:
Unity - / unity3d
Brackeys - / brackeys
Dani - / @danidev
Jabrils - / @jabrils
BlackthornProd - / @blackthornprod
Sykoo - / sykootv
Jason Weimann - / @unity3dcollege
Jonas Tyroller - / @jonastyroller
--------------------------------------------------------------------
- Website: unitycodemonkey.com/
- Twitter: / unitycodemonkey
- Steam: store.steampowered.com/develo...
❤ Watch my FREE Complete Multiplayer Course ua-cam.com/video/7glCsF9fv3s/v-deo.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) ua-cam.com/video/3yuBOB3VrCk/v-deo.html
Join your Players in MULTIPLAYER with Lobby! (Unity Gaming Services) ua-cam.com/video/-KDlEBfCBiU/v-deo.html
What is Unity Gaming Services? ua-cam.com/video/JwClCc2_zC8/v-deo.html
EASY Console! Run any Command! (Add Cheats, Set Gravity, Spawn Enemies Quantum Console Asset Review) ua-cam.com/video/bOf6CjpuSFs/v-deo.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
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!
Appreciate the video, great quality as always! I'm making my first venture into multiplayer and you've demystified quite a bit
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!
This Unity tool is amazing, I'm really happy it exists.🔥🎮✌🏻
Thank you for the great Tutorial 👍🏻
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!
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!!!!
Thank you so much for these awesome UGS tutorials!
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?
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 video is really so helpful!
Thanks a lot!
Thank you! Very useful!
Sweet!!! You da best Code Monkey!
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 👍
Thank you for the great content!
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
Wow this is phenomenal
Ahh, I got what I was looking for
You got yourself a new subscriber.
Thank you!
Love this high quality tutoiral with relay!
THANK YOU!
this is awesome!
Code Monkey is my hero!
Thank you! ⭐⭐⭐⭐⭐
Thank You
Awesome
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
thanks a lot for your great tutorials, i wish we have one for host migration
Super!
thanks so much
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
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?
very great video
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
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?
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
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
hey there!! would I be correct in assuming that as long as I have a relay running, one network manager, and a network object\transorm script on game objects, I have á multiplayer app?!? Thanks, Code Monkey!
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?
can you make a course on this for multiplayer only
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!
Could you make host migration with netcode for gameobject?(i don't know how to build at all)
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.
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!
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.
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
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.
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
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.
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
one more amazing tutorial! I'm still not 100% clear about these but I will be clear in time. I have a question that could be a silly one. for a one-to-one player matching, should we also use Lobby or just Relay enough for this? and can we pass some parameters like CreateLobbyOptions for creating a relay and join that relay by using the same parameters?
If you only want players to join each other directly (meaning no searching) then sure you can just use Relay. Just make your players share the Relay code to connect each other.
But if you'd like your players to be able to find each other, like allowing randoms to play together and not just friends, then Lobby is useful
You can pass whatever data you want on the Lobby options, it's generic data so it can be the Relay code or anything you want.
@@CodeMonkeyUnity many thanks for your answer. would you consider to create a tutorial (or course) that has Multiplayer, Lobby, Relay and Matchmaker?
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
Thanks for the great tutorials, I've done the Netcode for GO, Lobby and now this video several times. Still trying to work out the Lobby + Relay quirks I am experiencing but I never thought I would be able to get me and my buddy connected together across the net on my game demo test using a relay and join code!! Amazing! One question, if anyone can point me in the right direction. How would I get lets say, the 2 or 3,4 lobby players to spawn in certain places, instead of the default Netcode "Player Prefab" object location. Thanks!
You can check the OwnerClientId on the player and use that to position them in different places. Although the clientId can sometimes jump indexes, so best option is for the host to keep track of a list of connected players and use that, kind of like I did in my Kitchen Chaos game unitycodemonkey.com/kitchenchaosmultiplayercourse.php
@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
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.
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
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? Заранее спасибо за ответ
I am trying to create a relay, by using input field to join the game but it's not working can u explain how to join the game by using input field in relay services
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
Thanks for the great video! Super helpful!
I'm not sure you can change that in runtime however during testing I have found out you don't need to set it as Relay Unity Transport, you can leave it on just Unity Transport and it will work both with and without the relay, that's what I ended up doing on my Multiplayer course which has a mode with relay and a offline mode and both works ua-cam.com/video/7glCsF9fv3s/v-deo.html
@@CodeMonkeyUnity ❤ Thanks for the quick answer, I'll try that out. Keep up the amazing work and great attitude!
The IsLobbyHost & IsPlayerInLobby & GetJoinedLobby functions are in another video,
at timestamp 47min 30sec ua-cam.com/video/-KDlEBfCBiU/v-deo.html
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 :)
Just saving this as a reminder for later 8:02
Hi Codemonkey . I have been following your Multiplayer series and they are great. But please I need your help/Suggestions. How can I implement multiplayer code for a Board game like Ludo game . Do I have spawn the dice and coins for each player or just assign 2,3 player to the existing section ( Yellow, Green and Blue ) of the board the player is always assigned to the red section the board. I planning to use Netcode for gameobject and Unity's Relay /Lobby. Thanks for reply in advance. Thanks
I'm not familiar with what is a Ludo game but it appears to be a board game where each player controls a pawn? If so then each Pawn would probably be the player object, you could make just one set of dice owned by the server, and players would throw the dice by doing a ServerRPC, or alternatively you could also make dice for each player.
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 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
How can we create room for players but lobby to show who are available in the games?
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!
Hey, I've ran into a problem (probably a trivial one but im a begginer).
When loading a new scene, the stuff from the new scene won't be present on the new one. Right?
So this means that the connections and everything won't stay in the new scene.
Is there a way around this?
The connections will persist, you don't get a disconnect just because you loaded a different scene. Just make sure you're loading scenes through the NetworkManager and not the standard SceneManagement. unitycodemonkey.com/kitchenchaosmultiplayercourse.php#connectionsceneflow
Please make a video with matchmaker
Hello, i am having trouble in spawning different player for the player hosting and client hosting. Can u suggest anything to clear that up? Thank you so much
Instead of using the default player prefab you would connect to the server then use a ServerRPC to tell the server what prefab to spawn for that client. And after spawning it make sure you change the ownership so it belongs to that client and not the server.
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
what if the host cut the game window? what happen to the clients?
please give me information about this question 🙏🙏🙏🙏
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
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.
Really create tutorial!! This helps me a lot.
Can you tell me how I can read the steam name, if I use the unity lobby?
That would be relly great!
You would use the Steamworks API, really nothing to do with Lobby, it's completely separate
@@CodeMonkeyUnity thank you.
My problem is, that every code snippet I find in the internet, gets the SteamId over the steamlobby. Example:
CSteamID steamId = SteamMatchmaking.GetLobbyMemberByIndex( new CSteamID(callback.m_ulSteamIDLobby), numPlayers - 1 // this is the lobby ID of your friend, it syncs up with Mirror's lobby member ID );
So I don't know how I can access to the steamId from Unity Lobby.
The SteamAPI I have included.....
Hello I have a doubt, is it possible to make a game for WebGl using the multiplayer tools of Unity, because I see that 2 - 3 have only plans for WebGl in the future.
I believe they are working on an update to Unity Transport which is intended to support WebGL but as of right now not yet.
That's only for Netcode for Game Objects and Relay, you can use Lobby in WebGL
How to make it automatically start with any random lobby
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.
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?
@@ScarTS500 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.
Hi sir, very useful video. I thought it was possible to use Relay service only with their servers. But from what I understand in this video I can also host it on my server right? Sorry again for the ignorance, but by using a Relay server we are creating a p2p system?
The Relay is a Unity server. If you want P2P you need to not use Relay and just connect the host directly to the clients, but that involves handling port forwarding
@@CodeMonkeyUnity Hi! Do you know where I can find a tutorial for this? I want to make a P2P multiplayer game for Unity but without using Unity Gaming Services.
Thank you. But I use mirror, how i can adapt the code
You need to grab the data (ip, port) from the relay and give that to Mirror when hosting/connecting. I haven't used Mirror so not sure on the specifics
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.
Can we make multiplayer games without server costs? Like peer 2 peer where no server fees are involved?
Yes, NGO by default is p2p completely free
For anyone having trouble finding it UnityTransport is in the following namespace: Unity.Netcode.Transports.UTP
ty
What is the difference btw photon and unity netcode.And which is better one in performace and pricing .
They are completely different tools that do the same job, networking. I haven't used Photon myself so can't really speak to direct comparisons
Is there a function to end the connection on the client? like RelayService.Instance.LeaveAllocation?
The client never touches the relay, you would simply disconnect through NGO with NetworkManager.Singleton.Shutdown();
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
@ 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!
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
Does this works Globally or Locally
You said in the video there would be timestamps, but I see none :(
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
can you compare PUN2 and this...thank you...
This. Seems like PUN is doing all this for you already automatically
can you make a tutorial on Async tutorials like the good old days?
That would be a great idea! I still find them a bit confusing so doing a quick tutorial would also help me understand them better
Can we implement chat system and video call using Netcode ?
Using Netcode yes, using Relay for Video streaming no, that is against their rules docs.unity.com/relay/introduction.html
If you just use Netcode without Relay you can use your own dedicated server for whatever you want
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