Setting the parent of a child’s Transform directly in Unity always uses the default WorldPositionStays value of true. It is recommended to use the NetworkObject.TrySetParent method when parenting if you plan on changing the default value. The new parent for this NetworkObject transform will be the child of, and if true, the parent-relative position, scale, and rotation are modified so that the object keeps the original position.
In the first post of this series covering the complete landscape of Unity Realtime Multiplayer, networking basics and key considerations are discussed. To set up a basic networking game with at least one GameObject in a scene that isn’t the player, a script can be added to the player Prefab that adds parenting to its transform via the Master Server. A ‘NetworkObject’ parenting solution within Netcode for GameObjects (Netcode) helps developers with synchronizing transform parent-child relationships of ‘NetworkObjects’.
Child objects can appear strange if they don’t understand their positioning and how it relates to the parent or game world. A NetworkObject component can only be parented if it’s spawned and can only be parented under another spawned NetworkObject component. To save bandwidth, the item instance on every client should be parented to the controller instance under the spawned NetworkObject component.
Direct parenting of network entities in coherence happens with a simple transform.SetParent(). In a co-op game using Photon Unity, parenting can be used to move objects with respect to other objects. Instead of parenting, the NGO in script can be “parent” by setting its position relative to the fake parent.
📹 Unity How to Detach From Parent
To detach from a parent in unity you just have to set the transform.parent = null; FREE 2D Platformer Art Pack + MORE FREE …
How do you select parent by default in Unity?
In order to designate a game object as the default parent, the user should right-click and select the option “Set as Default Parent.” The game object will then be highlighted in the scene hierarchy.
How does networking work in Unity?
Unity networking system consists of a server and multiple clients, with one client acting as the server when no dedicated server is available. The host is a server and client in the same process, using a special client called the LocalClient, while other clients are RemoteClients. The networking system aims to maintain the same code for LocalClients and RemoteClients, reducing the need for developers to consider multiple client types.
In Unity, GameObject. Instantiate creates new Unity game objects, but objects must also be spawned to be active on the network. This can only be done on the server, causing objects to be created on connected clients. The Spawning System uses distributed object life-cycle management and state-synchronization principles to manage objects once they are spawned.
What is a child object in Unity?
Unity’s hierarchical structure is based on a system of ordered hierarchies, wherein the children are confined to the boundaries set by their parents. Such GameObjects are susceptible to the placement, rotation, and scale of their parent, and once generated, the parent governs the GameObject.
Can you parent bones in unity?
In Create Chain Bone mode, newly created bones are automatically parented to the previous bone in the hierarchy, while in Free Bone mode, new bones are parented to the currently selected bone regardless of their position in the hierarchy. Unity Technologies holds the copyright for “Unity”, Unity logos, and other Unity trademarks, while other names or brands are trademarks of their respective owners. The document was generated by DocFX on 18 October 2023.
How to parent objects in Unity?
GameObjects can be parented by dragging and dropping them onto the desired parent, which is represented by a small indentation and an arrow next to the parent object. Parenting GameObjects has various uses, such as separating different parts of a tank into separate GameObjects and parenting them under a single “tank” GameObject. This ensures that all parts move with the parent’s movement. In the next lesson, we will discuss internal assets and learn how to create and manage them in a project.
How do you create an empty parent in unity?
Unity’s Hierarchy window displays all GameObjects, including characters, props, scenery, cameras, and waypoints. Each GameObject’s functionality is defined by its attached components, such as models, cameras, or prefabs. The Hierarchy window can sort and group GameObjects used in a Scene, and when adding or removing GameObjects in the Scene view, they are also added or removed from the Hierarchy window.
The Hierarchy window can also contain other Scenes, each containing the environments and menus of your game. Each unique Scene file represents a unique level, where you place environments, obstacles, and decorations. Unity uses parent-child hierarchies, or parenting, to group GameObjects, allowing you to link GameObjects together to help move, scale, or transform a collection of GameObjects. When moving the top-level object, or parent GameObject, you also move all child GameObjects.
How do you set parent objects?
To parent objects in a document, select two objects, first the child objects and then the parent object, and press Ctrl – P. The Set Parent To menu will appear, allowing you to choose from various parenting types. Confirming an entry in the menu creates a child/children to parent relationship, with the selected objects being’siblings’. The menu is context-sensitive, and the number of entries displayed may change depending on the selected objects. Changing the parent object’s child/children will not affect the parent, meaning the influence is from parent to child.
What are parent and child objects?
The terms “parents” and “children” are used to describe how objects relate to each other on the canvas. Parents are frames, components, or groups that contain other objects, while children are objects within a parent. Siblings are objects within the same parent. A frame with objects inside it is a parent, and any objects within it are children. A parent contains more than one object, and objects like frames, groups, and components can be both parents and children.
How do you create a parent-child relationship in the Unity IDE?
To create a Parent in Unity, drag a GameObject in the Hierarchy View onto another, creating a Parent-Child relationship. GameObjects with foldout arrows to the left of their names are parents. The Transform is crucial for storing a GameObject’s position, rotation, scale, and parenting state. It is not possible to remove or create a GameObject without one. Transforms can be edited in the Scene View or by changing their properties in the Inspector. In the scene, you can modify Transforms using the Move, Rotate, and Scale tools located in the upper left-hand corner of the Unity Editor.
How do I make my child ignore parent rotation in unity?
In order to create an empty game object and set the rotation to 0, 0, 0, it is necessary to set this object as the source of the rotation constraint. This configuration supersedes the rotation of the parent, which is the intended outcome. This solution may lack elegance, but it is worthy of consideration.
How does Unity earn money?
Unity Ads is a platform that generates revenue by displaying paid advertisements in games. The more traffic and impressions generated, the more money you can earn. Unity Ads offers different campaign types with different billing points and selects the highest-earning campaign. The average eCPM for Unity Ads depends on factors like platform, region, player demographics, and in-game placements, with the number of players being the biggest.
📹 Learn Unity Multiplayer (FREE Complete Course, Netcode for Game Objects Unity Tutorial 2023)
Learn How to Make Multiplayer Games with Unity in this massive FREE course! This is the followup to my singleplayer course, …
💬 Here is the Multiplayer Course! I really hope both of these FREE courses help you in your game dev journey! Hit the Like button! 🌍 Check the Course Website for FAQ and Related articles cmonkey.co/multiplayercourse 🎮 Play the game on Steam! cmonkey.co/kitchenchaos ❤ IF you can afford it you can get the paid ad-free version cmonkey.co/kitchenchaosmultiplayerpaidcourse 🌍 Check out my other Courses! ✅ unitycodemonkey.com/courses 👍 Learn to make awesome games step-by-step from start to finish. 🌍 Download the Project Files for all the Lectures cmonkey.co/freemultiplayercourse ⚡ Get Quantum Console (affiliate) assetstore.unity.com/packages/tools/utilities/quantum-console-211046?aid=1101l96nj&pubref=freemultiplayercourse 🔴 RELATED articleS 🔴 All links on the Course Page cmonkey.co/freemultiplayercourse Learn Unity Beginner/Intermediate 2023 (FREE COMPLETE Course) youtube.com/watch?v=AmGSEH7QcDg COMPLETE Unity Multiplayer Tutorial (Netcode for Game Objects) youtube.com/watch?v=3yuBOB3VrCk Making a MULTIPLAYER Game? Join your Players with LOBBY! youtube.com/watch?v=-KDlEBfCBiU How to use Unity Relay, Multiplayer through FIREWALL! (Unity Gaming Services) youtube.com/watch?v=msPNJ2cxWfw EASY Console! Run any Command! (Add Cheats, Set Gravity, Spawn Enemies Quantum Console Asset Review) youtube.com/watch?v=bOf6CjpuSFs Take your Skills to the NEXT LEVEL by making a Turn-Based Strategy game!
Dude you are a god sent. I’m still finishing your other tutorial (work and life consume a lot of time and I apply every teaching on my own project to really understand the concepts so it’s taking me a while) but in the moment I finish the other tutorial I’ll start with this one. Just wanted to thank you for this incredible source of information, you are the best programmer out of the other game dev courses I’ve seen out there. I’ll support you buying other courses from you. Keep the good work!
Thank you for all you’re doing CodeMonkey! I got your Beginner to Advance tutorial a year ago and perusal this article now that I want to really tackle the multiplayer portion of my game is amazing! I’ll reach out in private for some questions you might be able to answer. Keep the good work man, you really are a great help
Thank you so much Code Monkey for this amazing journey. You are a legend. I learned a lot. I was not able to go full speed on this one but it’s done now. That’s what matters. Done and understood thanks to your teaching skills. Both courses are extremely valuable for the community. I hope you realize that with these free courses, you made a life changing move for some of us. For sure some people will access to a game dev career in a company or as an indie dev thanks to you. My future as a hobbyist is brighter than ever. Thanks a lot man!
Wow! This Unity multiplayer tutorial is an absolute gem! The amount of information packed into this 6-hour long article is astounding. I can’t thank you enough for putting in the time and effort to create such an informative and comprehensive tutorial. I’ve been struggling with understanding multiplayer functionality in Unity for a while now, but this tutorial has made it crystal clear. The way you explain the concepts and walk through each step is so easy to follow, even for beginners like me. I appreciate how you break down complex ideas into simple terms and provide examples along the way. It’s evident that you’re passionate about sharing your knowledge and helping others in the community. Thank you again for this outstanding tutorial. It’s people like you who make the Unity community such a fantastic place to learn and grow.
Hey CodeMonkey, I don’t comment much but I wanted to let you know even before these free courses, you’ve been a great help and inspiration to keep me going. You seem to always release a article just before I need a specific topic. I’ve started my journey a couple months back and you’re teachings have been pivotal. I’m still trying to find time to catch up to your breakneck output speed but man…keep em coming. Hopefully when my studio takes off, I can pass it forward as you’ve done and cite you as one of my founding pillars.
Been following you and your tutorials for years, and the Unity community couldn’t have asked for a better teacher. We all hope for your continued success, and hope the time and effort you’ve put into these two tutorials pays you back several times over, Hugo. You deliver like no other content creator in this space.
WOW, just wow. I just finished the course, and I’m just amazed how you remember all these minor details to make so much stuff. Thanks a lot for the course, as always it was on a top level. Idk if now I can make a multiplayer game myself, because there were many parts in the second half of the article there were difficult for me, but I’ll try to make one and handle all the problems when I get to them! Once again, thanks a lot!
This. Is. Awesome! Been a fan of your website since the beginning – this is amazing, next-level content and a huge milestone for your website. I’ve been looking forward to this article launching since you first teased it. Hope it gets a ton of views (and earns you a nice Unity sponsorship deal) – you deserve it! Picked up the paid courses also – more than happy to support your work! Congrats again and THANK YOU for sharing your time and talents with us.
For anybody that may encounter the same error. For some reason i was getting an error on the client (for example: StoveCounter tried to register with ScenePlacedObjects which already contains the same GlobalObjectIdHash” (This would happen on any of the counter objects in the scene and only happened on the client)). It fixed the issue if you go on the base counter and remove the Network Object and then re-add it. Idk why it randomly started doing that. Probably a bug that wasnt assignining new global IDs to the objects on the client therefor causing an error of duplicate IDs, but thats just my guess.
Just finished the course in parallel working on my own project! Thank you Code Monkey, you’ve been providing quality education for so long now! When I worry about having picked Unity as my engine, I remember that I chose it because it came with an amazing community of resources. You have been #1 on that list of resources for me. As someone impacted by the mass game dev layoffs (I worked in QA), it means a ton to me to be sharpening my skills at making actual games. Hope you realize that there will eventually be a ton of games out there that were made because of this website, and that number of games will be more than any one person could have made on their own. You’re truly a pillar of the indie game dev community!🐵
Trying to learn game dev is going through a jungle of content hoping that all the stuff you watch is compatible to each other and recent enough. BUT this and the earlier tutorial is a lifesaver, one person explaining everything you need to make a complete game, and even to make it multiplyer. Incredible. Cannot thank you enough.
Hey Code Monkey. Just want to say thank you for doing this kind of long and detailed tutorial. It was super helpful and I learn a lot. I have almost completed the tutorial and I’ve been frequently asking stuff in the unity community. Hope I can finish the game and publish it one day! But before hand I am going to watch your articles about marketing. Keep it up my man.
Thank you so much for these two courses Code Monkey! I have learned so much and I am very excited/confident to build an original game myself now. I do think the multiplayer course was more complex than the singleplayer, but you managed to explain all the difficult multiplayer concepts very well! Looking forward to what games/tutorials you will bring out in the future!
Few suggestions for some content releases…you can either make it as paid or free depending upon the complexity 1. Server Authoratative Implementation with Client Side Prediction and Lag Compesation, You can use the same Kitchen Chaos game for implementation 2. Integrating Addressables for gameobject loading and using it with Netcode…. 3. Realtime Timer implementation….games like Valor or clash of clans have real-time timer for building completion or attacks which is run from the server and is not dependent on client system, though I have implemented a crude way of realtime timer wanted to know how the Pros implement it. Not sure if you already have some content about it, but I was unable to find some decent content in youtube 4. Saving and loading data from Databases with Authentication services integrated and hosting it from Cloud storage or Cloud based databases (S3 or redis etc). I would be really happy to see if any of these suggestions could materialize
Just an extra token of appreciation to reflect the amount of effort you clearly put into this course, and all your other content that I have been perusal for years now. You’ve helped me put my demons to bed on never having been able to make a game using “Amos the Creator” (old-fashioned Unity) on my Commodore Amiga 30 years ago. 🙂
For anyone who encountered a problem on 3:42:10 regarding a Netcode warning on the Host which stops the game from loading the GameScene on multiplayer with the same warning below: (Netcode) Deferred messages were received for a trigger of type OnSpawn with key 0, but that trigger was not received within within 1 second(s). UnityEngine.Debug:LogWarning (object) Unity.Netcode.NetworkLog:LogWarning (string) (at ./Library/PackageCache/[email protected]/Runtime/Logging/NetworkLog.cs:28) Unity.Netcode.DeferredMessageManager:PurgeTrigger (Unity.Netcode.IDeferredMessageManager/TriggerType,ulong,Unity.Netcode.DeferredMessageManager/TriggerInfo) (at ./Library/PackageCache/[email protected]/Runtime/Messaging/DeferredMessageManager.cs:98) Unity.Netcode.DeferredMessageManager:CleanupStaleTriggers () (at ./Library/PackageCache/[email protected]/Runtime/Messaging/DeferredMessageManager.cs:83) Unity.Netcode.NetworkManager:OnNetworkPostLateUpdate () (at ./Library/PackageCache/[email protected]/Runtime/Core/NetworkManager.cs:1648) Unity.Netcode.NetworkManager:NetworkUpdate (Unity.Netcode.NetworkUpdateStage) (at ./Library/PackageCache/[email protected]/Runtime/Core/NetworkManager.cs:1538) Unity.Netcode.NetworkUpdateLoop:RunNetworkUpdateStage (Unity.Netcode.NetworkUpdateStage) (at ./Library/PackageCache/[email protected]/Runtime/Core/NetworkUpdateLoop.cs:185) Unity.Netcode.NetworkUpdateLoop/NetworkPostLateUpdate/<>c:b__0_0 () (at .
This is the best course that teaches you everything that you need to know, today I was trying to spawn the particle system on the multiplayer to try test my skills and after a few struggle it worked. Basically 1) instantiated the particle game object 2) grabbed the networkObject and spawned so that it spawns on the network 3) started the playing the particle after certain input (this one was a bit tricky as i had to play it on every single client, so I had to make a ClientRpc and called that from the server and passed the NetworkObjectReference to be able to play the particle system ). I was able to figure this out thanks to how well you have explained each concept.
Thank you so much for making all of these tutorials! Could you please also make a tutorial on client prediction/client reconciliation for Netcode? I’m still very much a beginner and I’m trying to understand how to get rid of that slight input lag. It’s super annoying, especially when you’re making a competitive game.
These two tutorials were awesome! Thank you for making these free, they really help understand how a full game comes together. I did run into one bug, but I’m not sure if it’s my version of Unity (2023.2.7f1), but the stove always shows the progress bar when taking the meat off it, but only on the client. It looks like the OnProgressChanged is running just after the OnStateChanged, so it ends up showing the progress bar with something like 0.1. I’ve downloaded the full project and it does it on there as well, so I suspect its the Unity version I’m using. I’m not sure how to get around it honestly! Again, thanks for the amazing tutorials!
Ok so I’ve hit my 1h mark for the course. Basically wanted to post a comment just because a nice intermission asking me how I am doing! I am doing great! Considering 1 month ago I was someone who knew veeery little about game dev I think I’ve come a long way in understanding how some of the cogs in game dev are working. And ALL thanks to you! What I have done is I have took your singleplayer course and finished it (1 and a half times XD), and THEN I took a bit different approach. I have started my own test game to really learn. What I did was make a concept for a game that is similar enough to your course that I can use the logic for making a game but different enough that I cannot fully refer to your course thus forcing me to use my brain in the max possible way. That allowed me to watch your course once again and really think about the ways you structure your games. You are a true GOLD and my master. My inspiration. I have made 1 “Full” (not really full but playable enough) demo game using that approach and now I have started this course directly on my own game. Still quite a lot of things different than here but I managed. If I hit a wall I will simply restart this course using KitchenChaos game I made and go from scratch to clarify, but so far, I looks like I understand enough to be able to apply the logic here to my game directly. I will prob put more comments in this article simply enough to raise visibility to it and help as much as I can. Once I finish this course I will of course go and pay for it cos you deserve it!
Loving the course so far! I’m up to 1:50:00🐒. You weren’t kidding about it getting more complex. At first the whole “a single client calling a Server RPC (with ownership required being false) which then calls a Client RPC so that the thing happens on all client versions” was a bit confusing but after seeing it implemented a couple more times in various situations I think I’m starting to understand it now.
First of all I want to THANK YOU A LOOOOT…I just finished the first part of ur course(Kitchen Chaos), and I learned tons, more than any other paid course I did so far, I want to work with game develop, and you gave me the confidence to do so, now I will start this 2nd part multi player, and after this I will buy ur “Unity Turn Based Strategy: Intermediate C# Coding” course…U are amazing a coach thank you again for share all your knowledge!!!
Thank you so much Code Monkey for these AMAZING courses. 6 months ago I completed the first course and since then I was able to release my first (simple) game on steam, participate in my first game jam, and also start my own game dev YouTube website. These courses have been the core part of how I learned to make games. I cannot thank you enough for these high-quality, life-changing courses, and I’m excited to move onto making bigger and better games ❤🙏🏼
58:37 first intermission ‘What has been the most challenging part so far’ – I’m perusal this article to gain a better understanding of how a multiplayer game can be built to better structure my project, I assume a lot of this will be explained as I continue the course but at the moment my brain is feeling overwhelmed at knowing what objects or data should be handled through a server and which are fine to leave alone. Looking forward to continuing the course and attaining a better understanding of this. Thanks again for this free course it has had a tremendous amount of value to me. thank you
Thank you so much for this course! I’ve already watched your lobby and relay articles so I was able to skip some parts but still found lots of helpful tips like using NetworkObjectReferences and Debugging with simulated lag to find those nasty errors. I’ve started a multiplayer project where players must work together (or sabotage each other >:D ) to navigate a forest and avoid getting eaten by a bear. Your tips will come in super handy!
Great course so far… at that “secret” pause point @1:50:11 Just learned something I wish I’d known before 😁…. the NetworkObjectReference bit you covered. I had been maintaining a dictionary to map NetworkObjects to local GameObjects in my game so I could pass things around and that felt like a really weird thing to do, but couldn’t get it to work otherwise, so I’ll be refactoring to use the refence you covered. So thanks for that!
Code monkey, thank you for creating these awesome courses! I already finished a singleplayer, and now I am making it multiplayer. While developing, I discovered, that if you enable the checkbox “Development build” in build settings (I am using Windows), a console will pop out right in the build if an error happens. You might find this helpful! Again, thank you so much for making articles that can help others to learn game development for free!
At about the 2 hour mark, and loving this series of articles. I have already been able to get a button to synchronize and update across Host and Client UIs which felt like a major accomplishment and was due to your articles. Still stuck on trying to get access to settings that are specific to client or host from the other party – in other words, one of the players chosses a particular type of ship and I would love that to show up in the UI of the other player, but so far having trouble with that – going to continue perusal the articles to see if the answer presents itself. Thank you, Code Monkey!
Hi again CodeMonkey! i have finished this tutorial it’s very amazing journey from the singleplayer course to the multiplayer, A rough one for the multiplayer because alot harder than singlerplayer and there’s difference version in my unity engine 2022.3.6f1 and netcode 1.5.2, i need some modification to the code for it’s work but it’s perfectly working now like the article! From this article too i learned that clean code from singleplayer make it’s easier to add feature like multiplayer like this! I hope you can make more course like this. Thank you very much for this course! 🐒🐒, I’ll continue my training to the advance turn base strategy course and i’ll see your there!!!
5:51:06 I cannot believe all the amazing things that I have learned. It has been a wild journey that was sometimes very difficult. But i simply took my time, took a deep breath and just tackled this project one step at a time. Thank you so much for all your hard work and wonderful educational tutorials.
I thoroughly enjoyed making ‘Starv’n Marv’s: Burgrr Khaos’ in the last tutorial. I am also currently working on a spin off bartending game, ‘Starv’n Marv’s: Last Call’. I just got my own Beer counter working, spawning an empty beer glass. Next up is creating a beer tap counter to fill the glass. Eventually, I’ll make the Veg counters Fruit Counters (lemons, Limes Oranges). The player will need to refill the garnish tray so that servers can garnish the cocktails. They will use prebatch cocktail counters to fill glasses, then will have to select the correct alcohol from various liquor counters, and use the Shaker counter to mix the drink, ready for delevery to the server station, or to the correct bar seat for the bar patrons. Then I’ll add different types of beer, a lager, an IPA and a stout. I’m very excited for this spin off, as it adds a few more levels of complexity to this already challenging game. While creating Last Call on the side, I’ll work on this course to make Burgrr Khaos Multiplayer, so that when Last Call is complete, I can quickly port that to multiplayer. I will share that game with you when it is complete, if you are interested. Thank you so much for making this tutorial, its been a great help along my GameDev Journey. Once I’m doing better financially, I’ll definitely donate to you and Brackeys for the help. Keep doing what you’re doing buddy!!!!
1:50:07 🐒 I think I’m starting to get the hang of it. Some of the functionality is a bit confusing at first, but I doubt it’s as confusing as implementing all the networking and syncing without Netcode. Once I learn all the rules and have some more practice, I’m sure things will click into place. Thanks for the course!
ok then at the next pause point @5:51:40 Loving the course, learned several things along the way that I can use to improve the project I’ve been working on. Since you asked its a hex-based wargame set in the Star Trek universe (obviously this is not a commercial project for me as I don’t own that IP). Always wanted a computer version of the game Federation and Empire by Star Fleet Games….so making it myself…lol
I really never leave a comment. But as a fellow developer that has always had a dream in the back of the head to make a game and explore the game developing scene i Thank You. The quality is very good and it will maybe open up a new chapter in my life. Hopefully a better one. You did a great job and a good deed by sharing this with the community.
Thank you so much, I’ve learned a lot! Finally done! When I first started the single player course I looked at the amount and felt nervous, I did a Mirror multiplayer course in the past but the project completely broke down despite my best attempts to follow along, even redid that previous course from a back up from the half way point and it still broke down. This is nothing against the mirror course, the instructor did his best but I’m sure I did something along the way. What I’m getting at is that the experience from that old course created uncertainty going into this one, but now that I’ve completed it I feel accomplished!
Something nice in 2023 version of Unity is the addition of the ‘Multiplayer Play Mode’ package which allows you to have up to 3 additional players for testing multiplayer within the Unity Editor without needing to build. This additionally attaches a console to each player, so you can debug them without using a 3rd party package. I’ve been following your tutorial series with the 2023 version and haven’t run into any issues, thanks for the very detailed articles! 🙂 The only difference in 2023 is the NetworkManager has a NetworkPrefabs ScriptableObject for storing prefabs instead of adding the prefabs directly to the NetworkManager.
for the sync trash counter section, why do you go through the multiplayer script and create a new function etc. Surely it is better to just call a server then client rpc from the DestroySelf() function? its a lot simpler, doesn’t require re-writing everywhere we destroy a kitchen object, and as far as I am aware isn’t dirty code at all. its just using the server rpc to client rpc pattern from before. here’s the code I wrote: public void DestroySelf() { DestroySelfServerRpc(); } (ServerRpc(RequireOwnership = false)) private void DestroySelfServerRpc() { DestroySelfClientRpc(); Destroy(gameObject); } (ClientRpc) private void DestroySelfClientRpc() { kitchenObjectParent.ClearKitchenObject(); }
ok sir, this is like my 3rd time commenting on your article just to give you huge thank and appreciation. I think we ALL here can agree that you are like a freaking saint to Unity newbie like me and us (at this point I’m more than ready to jump kick at people who disagree with me 😂) kindly reminder to other students, you can show support by buying his games, or purchase this course in the description. Let’s show him our support, my friend. He’s criminally under-thanked 🎉🙏🙏🙏
I am currently working on a C# code library designed to automate D&D game mechanics. Once it’s in a more polished state, I intend to make a Unity game that features it. That’s going to be a totally different hill to climb, but im looking forward to a change of pace once I get there. My library is in its third year of development already (very much an on-and-off project) and I want to see it get used 🙂 Ill definitely be referring to this article once I start working on the game.
2:22:34 Its actually a good idea to turn State into a Network Variable instead of doing RPC calls to update the State on respective clients because NetworkVariable, unlike RPC calls, can arrive on different ticks for each Client. So lets say if we had done an RPC call to update the state on the clients, it is possible that the RPC call executes first (State changes to State.Fried) but the Network Variable for fryingTimer’s OnStateChanged event fires after this RPC call which results in Warning sign being showed on some of the clients (Warning sign shows when State is Fried and Progress is >= 0.5f as coded in Single player course). But ofcourse in this case since both, State & fryingTimer, are NetworkVariables, they execute one after another and no bugs occur.
5:51:00 🙈 Absolutely wonderful course, and all for free! I’m still relatively new to Unity, so I’m definitely going to need to revisit this tutorial in the future, but I was able to follow along really well with everything! I picked up all of your courses on Udemy with the recent sale, and I can’t wait to get started on the tutorial for the turn-based strategy game 😄
🐒2:28:00 I decided to take a different approach for this article. Instead of playing in order – like I did in the singleplayer course – I am switching between reading documentation and going through the most important chapters. In the end, I basically watched the whole article already, and now I’m perusal it again sequentially. Yes, I’m finding multiplayer to be a greater challenge than singleplayer. Between some chapters I usually open my own project to fiddle with some things to answer my own questions like “what would happen if I didn’t use a ClientRpc here?” or “what would happen if I had 3 child NetworkTransforms, with each one syncing different things?”. It takes a bit long to complete the course this way but it creates more educational value to me. I also think I missed the Intermission at 1:50:00, although I’ve watched that chapter twice.
In 1:17:37 you could use this instead of crazy tweaks with extra events :3 private IEnumerator Start() { while (Player.LocalInstance == null) yield return null; // wait for next frame Player.LocalInstance.OnSelectedCounterChanged += Player_OnSelectedCounterChanged; } private void OnDestroy() { if (Player.LocalInstance != null) Player.LocalInstance.OnSelectedCounterChanged -= Player_OnSelectedCounterChanged; }
I WISH i had a course like this when i was beginning my game dev journey… That’s really a high quality course and I hope it will help a lot of people. I’ve also purchased your two udemy courses and now I only need time to watch them ! Do you plan on doing something similar when netcode for entities comes out ? For fast paced multiplayer games like third person shooter or driving games it should be great. Also it include some multiplayer concepts such as client side prediction / server side rewind which aren’t included in ngo. I would pay some cash for that !
I tried learning multiplayer when I first started learning game development and it was difficult. I have no idea whether I was just too green to understand it or if it was too complicated for me at the time. But now going through this, it’s insane how simple you make it seem. I’m about ~2 hours in but I feel like I can already go off and start working on a multiplayer game on my own! 🐵
Thank you for all the amazing work. This tutorial was awesome. I am very big fan. My only wish was that it touched on a few other multiplayer concepts like the host delivering more complicated data to the players etc. Like map data, saved player data etc. Do any of your other courses cover that? Because I’ll buy the heck out of them if they do lol.
1:50. Wonderful course so far, however I have encountered an interesting bug that I saw that a few others were having. For some reason when I tried to test that the plates were synchronized I kept getting several of the “NetworkPrefab hash was not found!” error message. In addition to this whenever the client went to place a KitchenObject like the meat patty or tomato onto a counter it would give me an error saying “NetworkObjectReference can only be created from spawned NetworkObjects.” I’m not entirely sure what caused this error, but after looking around I saw others suggesting to delete the Network Object component from the base counter prefab and then save, add the Network Object component back to the base counter prefab and double check that all counters had the Network Object Component. This did solve my problem and now everything is working as intended.
Hey CodeMonkey, first of all thanks for the free course. I’m having an issue with adding the Kitchen Objects to the Network Manager in the syncing Pick Up Objects chapter, the Network manager will not accept them to the list even though they have network object components and the Kitchen Object inherits from Network Behavior. If it makes a difference, my unity version is 2022.2.21, but I don’t think it should matter as I recall it should work the same as it is a 2022.2 version. Edit: Figured it out, apparently this version has a list of network prefabs lists. If you try to add one you get a default network prefab list created, just go to that list and add the prefabs there.
I have finished the course and want to say thank you CodeMonkey for providing us with the highest quality tutorials for free! I learned quite a bit and took a lot of notes! Everything was very well done so I appreciate all the work. However, there were a few bugs that I noticed in the end product that I’m using as a learning opportunity to fix. When in a lobby, the host can kick themselves, when kicking a player and they rejoin none of the player visuals show up, and it doesn’t really seem like the lobbies auto refresh and I want to add a manual refresh button. Those are just some of the initial things I noticed, but I can’t really complain with just how well everything else is. Again, thank you for providing this content.
So i finished the more gameplay focused parts, I’m at the GameState lecture, The course is nice, but 😀 a lot of things work because of the good architecture that was done in the first part. As someone how want to learn only multiplayer (and have not done the 10h course), i was expecting more explication on how everything work. At the end of the day yeah, i can read the code 😀 Nice job with the course, as someone how worked with Photon PUN and i want to go full Unity stack this is gonna help me a lot, Thanks!
I just finished it all and wanted to thank you for putting so much work into it. There is one thing that I still would like to see in the future which is some steam integrations. I would love to be able to use steam friends list as a way to join lobbies while also using some of the unity multiplayer services with NGO. Are there any good guides for how I would implement that in the current project?
1:50:15 🐵 The FAQ is very practical, thank you very much for this new work. I had already followed a fairly long tutorial with Mirror, I’m not surprised at the difficulties and pitfalls of switching to multiplayer. A lot to remember for an old brain like me :), but your article suits me perfectly. I find it unfortunate that errors are not reported either by Unity or by Visual Studio (like not adding ClientRpc to the function name of a ClientRPC, that doesn’t seem so complicated to me).
Just finished a course, thanks a ton for your hard work and for especially reading and answering comments here, even when you have your new steam game release deadline approaching. Small notice: Website page for this course has an error in “Lecture 26. Final Game” part: FAQ contains incorrect answer (answering the question from Lecture 25 FAQ), and also course/youtube links send users to a singleplayer course instead
I’m loving these courses! Thank you for making them! Quick note, this article shows a Play Again button on the Game Over screen, and I don’t believe that was done in the first course. I thought is was weird that I didn’t have it, and went back to try to find it, but couldn’t. I’m wondering if there were some features you either forgot to make for the tutorial, or accidentally left out while editing, or is there some follow-up article that I missed? I’m sure I can add the Play Again button myself, but I thought I’d bring it up to see if I missed anything.
Started this now! I’ve just about gotten through the first hour. I was successfully able to use the free console you mentioned in the August update. After I added it, I just had to turn off hide on awake. Then you can just click log on the console. One thing i may try to explore is letting more than one player play locally and letting another player join them online similar to how the latest iteration of overcooked does it.
First of all, great stuff Code Monkey!!! There’s a lot of praise for you in the comments of all your articles that I cannot think of anything original but to thank you once more. Quick Question… for the Lobby related timers (heartbeat), should we use “unscaledTimeDeltaTime”? I mean, it’s an external service not part of the game logic, if you Pause the game you skip the heartbeat, right? (I’m on marker 5:00:00, perhaps you addressed that afterwards)
Great tutorial yet again Code Monkey! Big fan. Can I request a article focused on assembly definitions and reducing build time? I’m using ParrelSync to avoid needing a build for every code change but it still has to compile in the editor for each code change. The time adds up. It’d be interesting to see how to tackle that appropriately.
Wow! What a great tutorial! Thank you so much. Super insightful to see the differences between SP and MP and the work that goes into converting SP into MP. Side note, any tips for learning to type as fast as you do? I try and use Alt+Enter and autocomplete as much as possible, but you’re still quicker than I am. Any Visual Studio settings that you have that help? No worries if not, might just be a skill issue.
I was waiting for this, liked & shared and started to watch! Thanks for your efforts! For a question I asked a while ago Unity “if we can use Steam transport for making server things free” unity has a repo called multiplayer-community-contributions that has different transports available. It looks like Unity people updated the repo to work with Netcode for Gameobjects v1.2
Another encountered issue 2:58:45 Sync Game state At this point, if you have 2 players and host will become ready first with client becoming ready second (as shown), everything is fine. But if the client will become ready first and only then host will become ready second, WaitingForOtherPlayersUI won’t be hidden. The reason for this is that at KitchenGameManager script in method GameInput_OnInteractAction() you at first call the SetPlayerReadyServerRpc() method, which includes checking if all players are ready and hiding Waiting…UI if necessary, and only then you call the OnLocalPlayerReadyChanged?.Invoke(), which shows the Waiting…UI. This causes the Waiting…UI to get hidden before it was even shown on the host side. Just change the order of these two lines (first invoke the event, then call the ServerRpc) and it’s fixed UPD: 3:00:45 Code Monkey also noticed this bug later and fixed it with exactly same solution
Thanks a lot for this article, it was a blast to follow and every possible cases are handled. I think it required a lot of time to made it, so thank you again for the efforts you put in it. Just a small suggestion, you seem to build the game each time you want to test a multiplayer feature. I know Unity plan to offer a solution where we can play the game multiple time for this purpose in the Editor but I didn’t find any information on that for now. What I use on my side is ParallelSync, with it you can open a new instance of the Unity project synchronized with the original one (it creates clone with syhmbolic links) and it’s a lot faster to debug like that! (and you have the Unity console on both side, so no need to install a plugin to have the console in game!)
Finally finished the free course and somehow the bugs that I was encountering were also fixed idk why. But since that’s the case, I’d like to thank you Code Monkey for this awesome free course. I’ll probably still go back and forth from here and to the single player article until I really familiarize myself and try to implement these to my other games. Thank you so much as this has been a real help!
Edit: After careful reviewing of my code, I have figured out the issue and have since fixed it. Thanks for the amazing tutorial CM! Amazing course! Been able to learn a lot of things that fel like magic until now. However I have ran into an issue that I’ve been pulling my hair out on for quite a while. For some reason every player has the host’s name above their head, I’ve spent the entire day troubleshooting and comparing the scripts with the provided download link and haven’t been able to fix this issue. May I ask if you have any idea what could be the cause of this? 😅
6:20:20 Thank you for this amazing content Hugo! I really learned a lot from it. I have a few questions: 1. What is the difference between making a multiplayer game with Netcode and PUN2? 2. How would you approach a single-multiplayer with gamepads? Do you have a tutorial on that? I am curious about it. (By single-multiplayer, I meant a multiplayer game that insn’t over through the internet, but rather, with the number of controllers). 3. Let’s say you want to construct a multiplayer system that requires local files. Is it possible to use cloud base approach for those files and sincronize between the players? For instance, a mesh / multiples images.
Hi, I’ve been following from the single player course and I’m halfway through this one. It’s fun. I just noticed the play again button on the game over scene, and I’m just wondering when it was added. It wasn’t on the single player course but it’s already created at the start of this one. Thanks for the guides! They’ve been very helpful.
It took me about 4 weeks to watch this course and integrate multiplayer on my game at the same time. I learned so much and it was def an interesting but also sometimes frustrating journey haha. But there is one question left for me: What are the last steps in order to publish a game on steam? Is it only to integrate the steamworks api or is it much more complex? I really appreciate the time and effort you put into these articles, thanks!
I finally finished the single and multiplayer courses. I lost count of the actual hours. They are excellent courses; the code is very clean, and I learned a lot. Bravo for a job well done! I can definitely use this as a starting point for my multiplayer games. My multiplayer game has thousands of objects and “recipes,” so the for-next-loop lookup approach is not the best technique. What alternate methods could I use? Note that I also purchased the turn-based course on Udemy.
3:18:20 -> Are you handling the Play Again button in the HostDisconnectUI ? I see the serializefield, but didn’t look like that was used. I re-used the logic from the GameOverUI -> Loader.Load(Loader.Scene.GameScene);, but with the Host leaving, would the NetworkManager or other areas need to be modified to use a new Host?
Nice tutorial, best one that I saw until now, thank you so much for the tutorial. I’m only having a problem and it is with the Kick Player function, I can’t make it work properly for some reason, I made almost everything like you did, the code works, it kicks the player and everything, but the only problem is that the player kicked doesn’t know it was kicked because he doesn’t leave the Lobby, it gives an error saying that it can’t access the Lobby services and basically the game freezes for the kicked player.
Course is awesome, i’ll point that out every comment 😀 I got a new question, I was planning to base my pve coop fps game on this. In general I figured I should make the base singleplayer first in order to at least understand core functions. yes it can take time to convert it into multiplayer but I fear I’m not experienced enough to make it multiplayer from start
Hello man! Great work on both tutorials! Watched this one first, then decided to go properly and went to this netcode exclusive then the Single-player game, and now I am in the process of rewatching this (trying to decide whether I’ll write the code along with you, as I did in the single player or skip it XD). I am about to do my thesis, and I am going to (try to) make a multiplayer quiz game with unity. I already have gotten some ideas from you, but still not sure. For instance, I’m thinking the even though the synching of the delivery manager seems straightforward, and I could use it to sync questions, most likely I’ll have to use Network Variables, since I do want to handle late joins/async gameplay. I was also thinking about playing with something like the Delivery Manager for the whole game (since it is going to be a pretty simple quiz game). Sorry for the long text, even if you don’t have time to read/answer, again thanks for the articles, hopefully I’ll manage to do something.
I just hit the Intermission. The most difficult thing so far has been determining the cause of a one off error, the error stated that port 7777 was already in use and both client and host crashed. However, I restarted both games and have been unable to reproduce the error. I hope it doesnt reoccur later down the road for a player. Other than this, since I watched the suggested 1 hour Netcode article, this tutorial has been easy to follow. Thanks CodeMonkey!
Hey CodeMonkey, i have just finished the course and i just have one word to describe it “wonderful” this course is incredible, one thing to say maybe would be that i would like to know more about relay and netcode but i am going to check your other articles where you explain more about it. Btw i found and error in your game that affects mine too, if i create a lobby, and i join with client, then i go to main menu with the host, it gets an error that stops the game and the lobby remains visible but you can’t connect on it anymore.
I finished the first part a good month and a half ago and now I’ve finished the second. Thank you so much, dear Hugo, for this great course! This week I also bought your “ultimate-unity-overview” course and would like to gain some experience with it before starting my own project. I do have one question though, but maybe it will be answered in the course. We only saw the possibility of an online lobby in the course. Is it also possible to create an offline or LAN lobby in Unity? I have read something about “UNet” and “Network Discovery”, but according to Unity this is deprecated. Could you give me a tip? THX:_cmkCmk:!!!
For ANYONE facing the issue Xgameobject tried to registered with ScenePlacedObjects which already contains the same GlobalObjectIdHash Value (###### (insert number here)) for YGameobject this is what i found codemonkey said in a forum: (basically, its a random problem, just remove and add the networkgameobject) I just had this exact issue with NGO 1.2.0 Last night everything was working but now tried to run the exact same game and got that very strange error. For some reason all the prefabs placed in the scene that were all copies of the same prefab ended up with the exact same GlobalObjectIdHash (although they each had a different NetworkObjectId) I removed and re-added the NetworkObject, didn’t change any code, and everything works again. Very strange Thanks for this post!
Thank you so much for all that you do! You have crammed SO much into this 16 hours, there is hardly any filler time the further you get, so its a LOT of knowledge to take in. I’ll probably go back to the single player tutorial and re-watch a few chapters that didn’t sink in while I’m building new counters for my bartending game. Next up in my GameDev Journey, a Turn Based RPG! Thanks Code Monkey!
2:28:00 should also replace the code when the player picks up the meat directly from the stove with a plate, because its trying to overwrite the same function, here is the code for the Interact in case anyone is getting an error, but it should be easy to fix public override void Interact(Player player) { if (!HasKitchenObject()) { // There is no KitchenObject here if (player.HasKitchenObject()) { // Player is carrying something if (HasRecipeWithInput(player.GetKitchenObject().GetKitchenObjectSO())) { // Player carrying something that can be Fried KitchenObject kitchenObject = player.GetKitchenObject(); kitchenObject.SetKitchenObjectParent(this); InteractLogicPlaceObjectOnCounterServerRpc( KitchenGameMultiplayer.Instance.GetKitchenObjectSOIndex(kitchenObject.GetKitchenObjectSO()) ); } } else { // Player not carrying anything } } else { // There is a KitchenObject here if (player.HasKitchenObject()) { // Player is carrying something if (player.GetKitchenObject().TryGetPlate(out PlateKitchenObject plateKitchenObject)) { // Player is holding a Plate if (plateKitchenObject.TryAddIngredient(GetKitchenObject().GetKitchenObjectSO())) { GetKitchenObject().DestroySelf(); SetStateIdleServerRpc(); } } } else { // Player is not carrying anything GetKitchenObject().SetKitchenObjectParent(player); SetStateIdleServerRpc(); } } }
Finally completed this project, learnt a ton and look forward to making some games with what I’ve learned. Enjoyed the Unity Services integration and discussion/examples of other services(Matchmaker etc). Do you cover coding game difficulties in your courses(Had a search on your website but nothing came up with regards to ‘difficulty’)? In a recent game, leveraged Graph API for a “Guess Who” style game at work (fetched employee’s photo and interests etc) to help newcomers get to know people(harder due to WFH being more prevalent). The game contained different difficulties (e.g., normal: first name, hard: first name and surname) which the employee had to type in and variables (game length, hiding objects) tied to difficulty. Had to check difficulty in multiple methods, code got messy. Any suggestions? Excited to refactor previous project using techniques from your course, like using a script with a list of objects for difficulty instead of tags. Just started reading “Clean Code” based on your recommendation in “7 Steps to Become a Game Developer” guide. Thanks again for all your work on this project and the single player and all your other articles which I’m slowly getting through! 🙂
Hello! Once again, thank you so much for such amazing tutorial. It does cover everything one needs to get started; which is what I have done, and thanks to you I have succesfully implemented multiplayer mechanics to a game of mine. I do however have found a problem when trying to add this functionality to my game’s VR version: All players are rendering the same camera, I don’t know if this has to do only with VR, but I do think this affects First Person in general, as even when every player has their own one, in the end, all clients see the same camera assigned to one of them. I hope you can help me some way, and if I find the solution on my own, I’ll be sure to share it here so anyone facing this problem can solve it.
5:13:50 I don’t agree. What if the game crashes or the client is disconnected from the internet? Edit: After some tests, I found out that removing players from the lobby during the OnDisconnected callback has proven to be a much more effective approach to ensuring that players always exit the lobby when they do!
I think the most challenging part is going to be remembering the overrides for client auth. I don’t think I would have found the code without a tutorial like this or at least it would have taken way longer to figure out. I am curious if the resiliency is higher with client side auth or if the server side auth is able to handle host changes gracefully. I plan on using server side auth in my game eventually but I like the simplicity of client to learn.
just finished this and the singleplayer course and i wanted to thank you for your help im going to make my first game. just a quick question. does steam datagram relay is the same as unity relay ? and is it free? and if i used the steam datagram relay will i just need to replace the unity relay ? thank you for you time ❤❤
1:50:17 🐒 Awesome course so far! I started out using my own code from the previous course and had a really weird bug after making the pickup synced through the network. I could pick something up and put it down, but couldn’t pick the next thing up. It was great being able to download your code up to this point which helped me find the bug: in KitchenObject there was a overloading of the kitchenObjectParent variable. On to the next chapter ❤
Thanks so much CodeMonkey for 6 whole hours?!? of amazing learning content! I’ve always struggled to wrap my head around Mirror and the new NGO but your article helped a lot. I liked the repetition of modifying the code with rpcs which really cemented into my head how to use these functions. Currently at 2:30:24 and I hope to complete this article promptly.
Amazing tutorial. Just a question, on the “Character Select Lecture” you access PlayerData from the Player.cs to change the color ingame that the player chose from the lobby. I have noticed in my game I get an error and that’s because the playerDatanetworkList is empty! I am printing the list in Update on the MultiplayerManager.cs and on the Player.cs on the other scene. The first statement shows that the list is populated normally as it should even when the scene is changing. The other print though shows that the list is empty. Its like the list doesn’t exist for scripts on the other scenes. Any help please?
hello, great article as usual, one question tho, is it possible to lower the delay between what the player is doing and what the others see? Maybe by using lerp or sleep, because as you can see in your demo, when 1 of the 4 players move, there is a bit of delay, and in a multiplayer fps game, that could cause huge issues, what do you think could be the solution? Thanks again
Master, I have a question 🙂 Imagine you’re doing a chess multiplayer game. On one hand you want to have skins (chess shapes and colors). On the other hand you want to have different lobbies: private games (to play with friends), fast games (quick joins) and ranked games (some kind of elo system, leaderboard and so on). My question is about the multiplayer architecture, should you go for a host+client or should you use the multiplay, dedicated server and so on? I have doubts about where to store the elo in the host+client, because if you store it locally in each client, if the person uninstalls the game, that is not stored anywhere and the data is lost, if someone wants to cheat, they can modify the local data easily, the same happens with the skins. So is there any way to have a “common database” like if it was a dedicated server that is a bit more controlled than storing things locally with PlayerPrefs?
As this excellent course progresses, I reflect on how I will apply the content. I want to do a small project with 2 Synty Studio characters and some backgrounds. I would like to use the starter assets, but if I see roughly how to organize this with the TPS for the 2 characters, I have a lot of trouble seeing how I can have the player character in FPS… The FPS is a capsule, so I think the players will not see each other? The solution might be to take the TPS, setting the virtual camera correctly. What do you think ?
Thanks for the amazing Course. I have a few questions. It would be great if you could answer them. So I use Addressables for Scene Loading. Is there a way to easily integrate this? Because on Mirror I did it and it was kind of complex. But I dont know if it makes sense to use Netcode from unity instead of Mirror. I´m new to Multiplayer so sorry if these are dumb questions. Also do you think it makes sense to implement Multiplayer if I have been coding for 3 years or do you think I should learn coding besides of Multiplayer better?
Hi CodeMonkey, first of all huge thanks for the great effort putting this together, it’s great to see clear explanations for the latest version of Netcode. I’m just under 6 hours in now and have hit a bug that is preventing me from getting over the finish line and really hope you can shed some light on. My setup is slightly different as the lobby and character select menus occur on the same scene. The lobby is seen first, they create a lobby and it connects as a host, then the other user clicks on the lobby item and they connect as a client. On click of each of the buttons the UI also swaps to show the character select at that point and players appear. When the players ready up and off they go… so far so good. My problem is that the network list is giving me a headache. If they disconnect via the main menu button (shutdown occurs) and then the previous client now tries to be a host and the previous host the client, the network list sees duplicates and the player select script activates 4 player objects when it calls the playerIndex < playernetworklist.count check. No matter what I try the network list count persists. I've tried to, clear the list (errors), dispose and reinitialize (error due to only be allowed to initialize the list in awake), destroy the network manager and multiplayer objects and instantiate new ones (problems syncing). No matter what I try, the list persists, I wonder if the list ownership is transferred to the network possibly? All I need to do is when the players disconnect by clicking the main menu button and shutdown() is called on the network manager, the list gets wiped so when they reconnect as a host it starts over again. there's gotta be an rpc call in there somewhere or something, but if the client disconnects why does the network list persist locally? Any insight into an approach you would take would be a massive help to get me over the 6 hour marker and finish this winner of a article. Sidenote: Regardless of if you can help or not, a super thanks will be coming your way when I get paid at the end of the month for creating this and helping with all other areas I was a little new to up to this point 🙂