How to use Unity Relay, Multiplayer through FIREWALL! (Unity Gaming Services)

  Рет қаралды 91,092

Code Monkey

Code Monkey

Күн бұрын

Пікірлер: 474
@CodeMonkeyUnity
@CodeMonkeyUnity 2 жыл бұрын
❤ Watch my FREE Complete Multiplayer Course kzbin.info/www/bejne/bZjPdKZ8bsupadU ✅ 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) kzbin.info/www/bejne/aarYc4J4aLulec0 Join your Players in MULTIPLAYER with Lobby! (Unity Gaming Services) kzbin.info/www/bejne/Y3ynnXh4m6h1n7c What is Unity Gaming Services? kzbin.info/www/bejne/gKimnXaZZ8SteZo EASY Console! Run any Command! (Add Cheats, Set Gravity, Spawn Enemies Quantum Console Asset Review) kzbin.info/www/bejne/mIDJZ3agpdqGfNU 🌍 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
@mctennys
@mctennys 2 жыл бұрын
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.
@gohugo472
@gohugo472 Жыл бұрын
do you have a video for inviting player to your library from steam ?
@hiii6377
@hiii6377 6 ай бұрын
I think the relay connection with NGO part is outdated, as I am getting errors of some of these types not existing
@BigBadFlag
@BigBadFlag Жыл бұрын
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; }
@aimojorma7674
@aimojorma7674 Жыл бұрын
Thank you! I was wondering why I got the "No instance" error whenever I tried to open my relay
@lazygoosegames702
@lazygoosegames702 Жыл бұрын
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!
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
I'm glad the videos helped you! Thanks!
@nixonscherbarth1974
@nixonscherbarth1974 Жыл бұрын
@NedjmouBlaxword73
@NedjmouBlaxword73 8 ай бұрын
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!!!!
@ChannelIsNotInUse
@ChannelIsNotInUse 6 ай бұрын
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.
@davidwestwood1459
@davidwestwood1459 Жыл бұрын
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)
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
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!
@InterloopStudios
@InterloopStudios 2 жыл бұрын
I was just thinking about making a multiplayer game and I remembered that Unity just made multiplayer easier. This is perfect timing!
@MegaMiley
@MegaMiley 2 жыл бұрын
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 :)
@CodeMonkeyUnity
@CodeMonkeyUnity 2 жыл бұрын
Yup! Having a simple fun scene for the players to test out the controls is a great use case
@durvesh007
@durvesh007 2 жыл бұрын
Let's go back to back multiplayer tutorials
@TheJangoo
@TheJangoo 10 ай бұрын
from where to start this whole tutorial step by step
@durvesh007
@durvesh007 10 ай бұрын
​@@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.
@TheJangoo
@TheJangoo 10 ай бұрын
@@durvesh007 got it thanks 👍
@thelegendarymushroom80
@thelegendarymushroom80 10 күн бұрын
I have git hub desktop installed, but i cannot install the git package in my unity, it tells me unable to be found :(
@LucaDev
@LucaDev 2 жыл бұрын
Lessgoo! I’ve been waiting for this! Finally I can take my multiplayer game online! Thank you (also first)
@cormo9058
@cormo9058 Жыл бұрын
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!
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
I'm glad the video helped you! Thanks!
@FuturPlanet
@FuturPlanet 11 ай бұрын
You said in the video there would be timestamps, but I see none :(
@MKUltraLT
@MKUltraLT Жыл бұрын
For anyone having trouble finding it UnityTransport is in the following namespace: Unity.Netcode.Transports.UTP
@Mendogology
@Mendogology Жыл бұрын
ty
@WacMilk
@WacMilk Жыл бұрын
The IsLobbyHost & IsPlayerInLobby & GetJoinedLobby functions are in another video, at timestamp 47min 30sec kzbin.info/www/bejne/Y3ynnXh4m6h1n7c
@jaybehl7567
@jaybehl7567 4 ай бұрын
thank u sm
@WattDesigns
@WattDesigns Жыл бұрын
Appreciate the video, great quality as always! I'm making my first venture into multiplayer and you've demystified quite a bit
@siavash4153
@siavash4153 Жыл бұрын
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
@CodeMonkeyUnity Жыл бұрын
Thanks for the kind words! I'm glad my videos have helped you! Thanks!
@siavash4153
@siavash4153 Жыл бұрын
​@@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?
@alec_almartson
@alec_almartson 2 жыл бұрын
This Unity tool is amazing, I'm really happy it exists.🔥🎮✌🏻 Thank you for the great Tutorial 👍🏻
@kpr2
@kpr2 4 ай бұрын
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!
@JesseTheGameDev
@JesseTheGameDev Жыл бұрын
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.
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
Yup researching Multiplay/Game Server Hosting is something I'd like to do, I'm currently busy with other projects but hopefully next month
@IsayBanj
@IsayBanj 3 ай бұрын
Thank you for the 3 tutorials i watched now
@-Bill-Clinton-
@-Bill-Clinton- Жыл бұрын
Thank you so much for these awesome UGS tutorials!
@susan6183
@susan6183 10 ай бұрын
Could you make host migration with netcode for gameobject?(i don't know how to build at all)
@TheKr0ckeR
@TheKr0ckeR Ай бұрын
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.
@LegendaryCombatForce
@LegendaryCombatForce Жыл бұрын
How to make it automatically start with any random lobby
@Nightmareblade-hg6fr
@Nightmareblade-hg6fr 9 ай бұрын
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?
@CodeMonkeyUnity
@CodeMonkeyUnity 8 ай бұрын
Did you define an Instance field in it? Maybe you named it 'instance' instead
@Nightmareblade-hg6fr
@Nightmareblade-hg6fr 8 ай бұрын
@@CodeMonkeyUnity i fixed it bc of a comment saying the bits of code you missed
@meaow7770
@meaow7770 2 жыл бұрын
Please make a video with matchmaker
@TheDrsalvation
@TheDrsalvation 2 жыл бұрын
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.
@CodeMonkeyUnity
@CodeMonkeyUnity 2 жыл бұрын
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
@TheDrsalvation
@TheDrsalvation 2 жыл бұрын
@@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.
@allankirui554
@allankirui554 Жыл бұрын
@@Quantiflyer life saver. thanks
@RigidDecay
@RigidDecay Жыл бұрын
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.
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
Simply sounds like you don't have any object with the RelayManager script, or you're not assigning the singleton Instance
@k3bolkb641
@k3bolkb641 3 ай бұрын
Photon or Netcode what should I use?
@vinhlam1401
@vinhlam1401 2 жыл бұрын
can you compare PUN2 and this...thank you...
@WowDailyDose
@WowDailyDose Жыл бұрын
This. Seems like PUN is doing all this for you already automatically
@virtual8207
@virtual8207 10 ай бұрын
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?
@BossAleks123
@BossAleks123 Жыл бұрын
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
@VoiceOfTheFutureYU 8 ай бұрын
Can you tell me how you did that?
@BossAleks123
@BossAleks123 8 ай бұрын
@@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.
@LeeSungHunHero
@LeeSungHunHero Жыл бұрын
Thanks for good video. I have Some questions. 1. If host Client has disconnected, relay room is destroyed? 2. If a new one doesn't have a joincode, how can find a relay room? 3. When someone is disconnected in a relay room, how can I check? 4. or When someone is connected in a relay room, how can I check?
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
Yes if the Host disconnects the connection to Relay (and NGO) is lost You cannot join a Relay without a JoinCode Seems you are confusing Relay and Lobby, Relay doesn't have "rooms", it just has peers being connected together.
@diegofonsecameire
@diegofonsecameire Жыл бұрын
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 :(
@MohamadsGarage
@MohamadsGarage Жыл бұрын
same here, did you solve it? also these docs unity provide won't help at all
@yours_indie_game_dev
@yours_indie_game_dev Жыл бұрын
so its not just me, how did you handle it
@ebrahimhsh
@ebrahimhsh Жыл бұрын
add using Unity.Netcode.Transports.UTP;
@miro7266
@miro7266 Жыл бұрын
This worked for me: using Unity.Netcode; using Unity.Netcode.Transports.UTP; using Unity.Networking.Transport.Relay;
@AmAs847
@AmAs847 5 ай бұрын
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.
@CodeMonkeyUnity
@CodeMonkeyUnity 5 ай бұрын
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.
@arjanb7158
@arjanb7158 Жыл бұрын
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?
@funkfollow9754
@funkfollow9754 Жыл бұрын
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?
@RyanShappa
@RyanShappa Жыл бұрын
I second this!
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
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
@funkfollow9754
@funkfollow9754 Жыл бұрын
@@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.
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
​@@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
@tadasegaming7360
@tadasegaming7360 Жыл бұрын
Really like you videos! keep it up. Did you provide the latest project on this video on your website?
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
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
@tadasegaming7360
@tadasegaming7360 Жыл бұрын
@@CodeMonkeyUnity Thanks man. Really appreciate it!
@RigidDecay
@RigidDecay Жыл бұрын
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?
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
You could include the version in the public Lobby data and only let players join if they have the same version
@yakwii800
@yakwii800 Жыл бұрын
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
@MTGameMaker
@MTGameMaker 2 жыл бұрын
can you make a course on this for multiplayer only
@dunc5623
@dunc5623 10 ай бұрын
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.
@JoaoGoncalves-np6su
@JoaoGoncalves-np6su Жыл бұрын
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)
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
I'm glad the videos have helped you! Obrigado!
@adamrespeliers2861
@adamrespeliers2861 Жыл бұрын
Thank you. But I use mirror, how i can adapt the code
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
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
@seanstpierre5900
@seanstpierre5900 Жыл бұрын
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
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
You need to initialize and sign in to Unity Authentication unitycodemonkey.com/video.php?v=1KSKRaacdKE
@Diskokeisari
@Diskokeisari Жыл бұрын
Did someone get it working with this with Lobby? i have trouble because there is code missing that cannot see in the video
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
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
@Diskokeisari
@Diskokeisari Жыл бұрын
@@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")
@Capbain
@Capbain Ай бұрын
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
@CodeMonkeyUnity
@CodeMonkeyUnity Ай бұрын
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
@nicouthe609
@nicouthe609 Жыл бұрын
Does Relay require a Internet Connection or would it also work offline with a LAN only scenario?
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
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
@Diskokeisari
@Diskokeisari Жыл бұрын
missing some code when adding lobby and relay together from LobbyManager...
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
What are you missing? The Relay additions are just a handful of lines which are all shown in the video
@Diskokeisari
@Diskokeisari Жыл бұрын
@@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")
@nemanjasekulic711
@nemanjasekulic711 3 ай бұрын
@@Diskokeisari how did you solve this problem?
@soumysahu
@soumysahu 2 ай бұрын
@@nemanjasekulic711 public const string Key_Start_Game = "Start" , Key_Game_Mode = "Survival"; in the main script
@soumysahu
@soumysahu 2 ай бұрын
@@nemanjasekulic711 public event EventHandler OnJoinedLobby; add this for all missing ones
@RigidDecay
@RigidDecay 2 жыл бұрын
Is there a way I could take a look at the demo project files shown in the video?
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
The only "complex" part is the lobby which you can download the project files from the lobby video
@RigidDecay
@RigidDecay Жыл бұрын
Alright thanks, I realize how simple it is to integrate relay now.
@souravde2029
@souravde2029 Жыл бұрын
I'm really desperate for multiplayer matchmaker. Please can you make a video on that.
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
Yup, it's on my list to cover, hopefully next month
@vijaydawrani4144
@vijaydawrani4144 Жыл бұрын
What is the difference btw photon and unity netcode.And which is better one in performace and pricing .
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
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
@deathdefiler4306
@deathdefiler4306 Жыл бұрын
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.
@gohugo472
@gohugo472 Жыл бұрын
do you have a video for inviting player to your library from steam ? or recommendation ?
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
You need to look into the Steam API for how to do that
@최동호-u9h
@최동호-u9h 5 күн бұрын
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.
@linkrider2302
@linkrider2302 Жыл бұрын
Is there a video like this but with netcode? Or is it possible to make this with netcode and lobby?
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
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 kzbin.info/www/bejne/bZjPdKZ8bsupadU
@linkrider2302
@linkrider2302 Жыл бұрын
@@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! ❤
@lcd11001
@lcd11001 Жыл бұрын
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
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
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.
@mjkkaya6056
@mjkkaya6056 Жыл бұрын
This video is really so helpful! Thanks a lot!
@Rush3fan1
@Rush3fan1 Жыл бұрын
@ CodeMonkey I got it working but wondering why I have to enclose the KEY_START_GAME in quotation marks while you're going without?
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
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
@Rush3fan1
@Rush3fan1 Жыл бұрын
@@CodeMonkeyUnity Oh lol I've never used const, but I now see why it's being used here after looking it up. Thanks!
@ChigosGames
@ChigosGames 8 ай бұрын
You got yourself a new subscriber.
@ZaMboo_9t5y
@ZaMboo_9t5y 8 ай бұрын
what if the host cut the game window? what happen to the clients? please give me information about this question 🙏🙏🙏🙏
@YanVaf
@YanVaf 2 жыл бұрын
Will you make a video about the unity CCD with addressables?
@CodeMonkeyUnity
@CodeMonkeyUnity 2 жыл бұрын
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
@nullx2368
@nullx2368 2 жыл бұрын
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.
@CodeMonkeyUnity
@CodeMonkeyUnity 2 жыл бұрын
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.
@nullx2368
@nullx2368 2 жыл бұрын
@@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 :)
@zbeb118
@zbeb118 2 жыл бұрын
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
@CodeMonkeyUnity
@CodeMonkeyUnity 2 жыл бұрын
A game mechanic where you would talk to an AI? That could be interesting
@SociopathDev
@SociopathDev 2 жыл бұрын
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?
@CodeMonkeyUnity
@CodeMonkeyUnity 2 жыл бұрын
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.
@fxy933
@fxy933 Жыл бұрын
Netcode, Lobby and Relay tutorials still up to date? Has anything changed significantly over the past seven months?
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
Netcode had a very minor change where the prefab list is now stored in a scriptable object instead of directly, other than that there have been no noticeable changes
@matanyamin1
@matanyamin1 2 жыл бұрын
Thank you! Very useful!
@DevChancey
@DevChancey Жыл бұрын
@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?
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
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
@joshuamiller7299
@joshuamiller7299 Жыл бұрын
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!
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
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
@ProdbyMaxim
@ProdbyMaxim Жыл бұрын
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
@CodeMonkeyUnity Жыл бұрын
It usually says that when you stop playing and it closes the server
@ProdbyMaxim
@ProdbyMaxim Жыл бұрын
@@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?
@ProdbyMaxim
@ProdbyMaxim Жыл бұрын
nevermind i fixed it, i just had to put relay on and off 100 times :)
@thejuicedorange9317
@thejuicedorange9317 Жыл бұрын
@@ProdbyMaxim ? I'm having the same issue?
@ProdbyMaxim
@ProdbyMaxim Жыл бұрын
@@thejuicedorange9317 just put relay on and off 100 times in the unity website
@anujsaini0271
@anujsaini0271 Жыл бұрын
How can we create room for players but lobby to show who are available in the games?
@itayp2405
@itayp2405 Жыл бұрын
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?
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
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
@itayp2405
@itayp2405 Жыл бұрын
@@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
@MrRevelance
@MrRevelance Жыл бұрын
thanks a lot for your great tutorials, i wish we have one for host migration
@Channel-gx2ct
@Channel-gx2ct Жыл бұрын
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
@DallaswithaD
@DallaswithaD Жыл бұрын
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?
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
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.
@marksmithcollins
@marksmithcollins 2 жыл бұрын
So Is Unity Relay a remote server service for hole-punching techinque?
@CodeMonkeyUnity
@CodeMonkeyUnity 2 жыл бұрын
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
@yuangdong406
@yuangdong406 6 ай бұрын
@@CodeMonkeyUnity t acts as the intermediary between players mean it may cost more delay time?
@moranyt8299
@moranyt8299 Жыл бұрын
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? Заранее спасибо за ответ
@iliachakarov7285
@iliachakarov7285 Ай бұрын
Hugo is the best!!
@jamesprise4252
@jamesprise4252 Жыл бұрын
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!
@UNNIETKTJ
@UNNIETKTJ 8 ай бұрын
8:50 caramba!!! Você vive em Portugal, já sabe falar português???
@CodeMonkeyUnity
@CodeMonkeyUnity 8 ай бұрын
Eu sou português por isso sim! heh
@leadaf
@leadaf 11 ай бұрын
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.
@leadaf
@leadaf 11 ай бұрын
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.
@ViktorTCG
@ViktorTCG Жыл бұрын
I have a very strange error... When I run Lobby and Relay, after 5 seconds my wifi goes down
@gianttwinkie
@gianttwinkie Жыл бұрын
Is a CCU while they are signing in or the entire time they are playing the game?
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
It's concurrent, so while they are connected to the Relay
@krujero
@krujero 2 жыл бұрын
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?
@DwightPotvin
@DwightPotvin 2 жыл бұрын
Any advice on how to handle a 3D / interactive lobby opposed to a UI?
@CodeMonkeyUnity
@CodeMonkeyUnity 2 жыл бұрын
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.
@DwightPotvin
@DwightPotvin 2 жыл бұрын
@@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 .
@matteomangani
@matteomangani Ай бұрын
How do i call the JoinCode function from another code? if i write "Joincode()" it doesn't work
@CodeMonkeyUnity
@CodeMonkeyUnity Ай бұрын
It's a normal function so you can call it like you would any other function If you're not familiar with C# then check out my C# beginner course kzbin.info/www/bejne/poPIg2mQbtd-Y9E
@ChiakaChima3D
@ChiakaChima3D 11 ай бұрын
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
@CodeMonkeyUnity
@CodeMonkeyUnity 11 ай бұрын
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.
@muhammadinaammunir6761
@muhammadinaammunir6761 10 ай бұрын
Can we make multiplayer games without server costs? Like peer 2 peer where no server fees are involved?
@CodeMonkeyUnity
@CodeMonkeyUnity 10 ай бұрын
Yes, NGO by default is p2p completely free
@netanelkomm5636
@netanelkomm5636 Жыл бұрын
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!
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
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
@yours_indie_game_dev
@yours_indie_game_dev Жыл бұрын
if get the time would you do like a networkdiscovery tutorial, where client discovers client but in offline mode
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
I'm not entirely sure what you mean by that but it sounds similar to the Async Multiplayer that I covered here unitycodemonkey.com/video.php?v=EEQfSmK1nXA
@yours_indie_game_dev
@yours_indie_game_dev Жыл бұрын
@@CodeMonkeyUnity not exactly, i meant where no one needs to be online and then when someone hosts before starting client one can press a button to discover host in the same lan, but ive been told that feature doesnt currently exist in netcode. although thanks for that video you sent its information is also useful
@d2b906
@d2b906 Жыл бұрын
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
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
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
@pingu2538
@pingu2538 Жыл бұрын
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
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
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.
@TheJokerCard21
@TheJokerCard21 Жыл бұрын
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?
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
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
@TheJokerCard21
@TheJokerCard21 Жыл бұрын
@@CodeMonkeyUnity ok perfect thanks you!
@RigidDecay
@RigidDecay Жыл бұрын
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.
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
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
@RigidDecay
@RigidDecay Жыл бұрын
@@CodeMonkeyUnity you won’t see this probably but thanks so much for responding to your comments, it’s amazing.
@pitonto
@pitonto Жыл бұрын
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
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
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
@RyanShappa
@RyanShappa Жыл бұрын
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!
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
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
@RyanShappa
@RyanShappa Жыл бұрын
@@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
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
​@@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
@RyanShappa
@RyanShappa Жыл бұрын
​@@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.
@jesusvelaortega3878
@jesusvelaortega3878 Жыл бұрын
Please, would it be possible to have the project files and be able to download them? Thank you very much.
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
I did make downloadable project files for the Lobby scene, I didn't make them for this one since it's really just one extra line of code unitycodemonkey.com/video.php?v=-KDlEBfCBiU
@christopherrapczynski204
@christopherrapczynski204 11 ай бұрын
@@CodeMonkeyUnity uuuuuuh what? not even close to just being one line of code, you added a variable in lobby ui that you never showed, you greened out start in testRelay and made it an instance, you made the bottom functions public, you added a bunch of stuff to lobbymanager, dude what the hell is going on in this particular video? the others were really good, this one completely falls apart here
@hugoslugehugo405
@hugoslugehugo405 2 жыл бұрын
Can't seem to get the KEY_START_GAME at the end of the video right. anyone got the full code so I can try and find an answer?
@CodeMonkeyUnity
@CodeMonkeyUnity 2 жыл бұрын
What exactly cant' you do? You just request the relay code and update the lobby data with that code
@RigidDecay
@RigidDecay 2 жыл бұрын
Wow this is phenomenal
COMPLETE Unity Multiplayer Tutorial (Netcode for Game Objects)
1:04:05
This Game Is Wild...
00:19
MrBeast
Рет қаралды 199 МЛН
What type of pedestrian are you?😄 #tiktok #elsarca
00:28
Elsa Arca
Рет қаралды 38 МЛН
One day.. 🙌
00:33
Celine Dept
Рет қаралды 56 МЛН
Lamborghini vs Smoke 😱
00:38
Topper Guild
Рет қаралды 39 МЛН
P2P or Dedicated Servers? What's the best for your unity game?
7:35
Jason Weimann (GameDev)
Рет қаралды 10 М.
I Made the Same Game in 8 Engines
12:34
Emeral
Рет қаралды 4,2 МЛН
Why Solo Developers Should Use Unreal
9:51
Thomas Brush
Рет қаралды 435 М.
Why Don't You Make Your OWN Game Engine?
7:23
Skeffles
Рет қаралды 14 М.
Build a Multiplayer VR Game in just a Few Clicks - Meta Building Blocks
17:53
Making MULTIPLAYER Games has never been EASIER!
12:49
Code Monkey
Рет қаралды 84 М.
How to setup Global Matchmaking for Unity
12:27
Tarodev
Рет қаралды 76 М.
Why Making Multiplayer Games SUCKS
6:46
Tom Weiland
Рет қаралды 434 М.
Optimizing my Game so it Runs on a Potato
19:02
Blargis
Рет қаралды 661 М.
This Game Is Wild...
00:19
MrBeast
Рет қаралды 199 МЛН