{"id":32041,"date":"2024-11-01T09:05:12","date_gmt":"2024-11-01T09:05:12","guid":{"rendered":"http:\/\/atmokpo.com\/w\/?p=32041"},"modified":"2024-11-01T11:33:34","modified_gmt":"2024-11-01T11:33:34","slug":"unity-basic-course-joining-a-network-room","status":"publish","type":"post","link":"https:\/\/atmokpo.com\/w\/32041\/","title":{"rendered":"Unity Basic Course: Joining a Network Room"},"content":{"rendered":"<p><body><\/p>\n<p>Hello, everyone. In this tutorial, we will explore how to join a network room in Unity. Multiplayer game development is a very exciting and challenging field, and here we will understand the basic networking functions and explain step-by-step how to join a room.<\/p>\n<h2>1. Basics of Unity Networking<\/h2>\n<p>Unity provides various networking solutions. The solution that we will cover here is Unity&#8217;s <strong>UNet<\/strong>. UNet is a feature that helps easily develop multiplayer games in Unity. Important elements of UNet include:<\/p>\n<ul>\n<li><strong>Server and Client<\/strong><\/li>\n<li><strong>Network Manager<\/strong><\/li>\n<li><strong>Network Identity<\/strong><\/li>\n<li><strong>Network Behaviour<\/strong><\/li>\n<\/ul>\n<h3>1.1 Server and Client<\/h3>\n<p>The server manages all the data of the game, and the client connects to the server to send and receive data. This is essential for synchronizing all objects and states within the game.<\/p>\n<h3>1.2 Network Manager<\/h3>\n<p>The Network Manager is a crucial component for network games, setting up network connections and managing clients and servers. With this component, you can easily create and join game rooms.<\/p>\n<h3>1.3 Network Identity<\/h3>\n<p>Network Identity is a component that allows game objects to be uniquely identified on the network. Without this component, clients will not be able to recognize objects.<\/p>\n<h3>1.4 Network Behaviour<\/h3>\n<p>Network Behaviour is a base class for scripts that allow networking functions. You can inherit from this class to implement functionality that operates between clients and servers.<\/p>\n<h2>2. Preparing a Unity Project<\/h2>\n<p>Now, let\u2019s prepare a simple Unity project for practice. Please follow these steps to set up the project:<\/p>\n<h3>2.1 Installing Unity and Creating a New Project<\/h3>\n<p>Install Unity and create a new 2D or 3D project. We will name the project &#8216;NetworkRoomExample&#8217;.<\/p>\n<h3>2.2 Importing Required Packages<\/h3>\n<p>Use Unity&#8217;s package manager to import the necessary networking support packages. Click on <strong>Window -&gt; Package Manager<\/strong>, search for <strong>NetworkManager<\/strong> in the <strong>Unity Registry<\/strong>, and install it.<\/p>\n<h3>2.3 Setting Up the Basic Scene<\/h3>\n<p>Create a scene and add Unity&#8217;s default canvas. Then, design the UI to add buttons for joining and creating rooms.<\/p>\n<h2>3. Creating and Joining Rooms<\/h2>\n<p>Based on the retrospective, we will write scripts to create and join rooms. To do this, create an empty GameObject in Unity and add the <strong>NetworkManager<\/strong> component.<\/p>\n<h3>3.1 Setting the NetworkManager<\/h3>\n<pre><code>using UnityEngine;\nusing UnityEngine.Networking;\n\npublic class CustomNetworkManager : NetworkManager {\n    public override void OnStartServer() {\n        \/\/ This is called when the server starts.\n        Debug.Log(\"Server started\");\n    }\n}\n    <\/code><\/pre>\n<h3>3.2 Room Creation and Joining Script<\/h3>\n<p>Now we will create a UI script for the functionality to create and join rooms. Please refer to the code below:<\/p>\n<pre><code>using UnityEngine;\nusing UnityEngine.Networking;\nusing UnityEngine.UI;\n\npublic class RoomManager : MonoBehaviour {\n    public Button createRoomButton;\n    public Button joinRoomButton;\n\n    void Start() {\n        createRoomButton.onClick.AddListener(CreateRoom);\n        joinRoomButton.onClick.AddListener(JoinRoom);\n    }\n\n    public void CreateRoom() {\n        NetworkManager.singleton.StartHost();\n        Debug.Log(\"Room created\");\n    }\n\n    public void JoinRoom() {\n        NetworkManager.singleton.StartClient();\n        Debug.Log(\"Joining room...\");\n    }\n}\n    <\/code><\/pre>\n<h3>3.3 Connecting the UI<\/h3>\n<p>To use the above script, reference the buttons in the Unity Editor and connect the join and create functionality. You can design the networking UI yourself to provide an intuitive experience for users.<\/p>\n<h2>4. Functionality of the Network Room<\/h2>\n<p>Now that all the settings are complete, test the room creation and joining features. You can run two instances of Unity to create and join rooms simultaneously to check if communication is working properly.<\/p>\n<h2>5. Troubleshooting<\/h2>\n<p>Here are some common issues that may easily arise when using networking features:<\/p>\n<ul>\n<li>Unable to connect to the server: Make sure the room has been created successfully.<\/li>\n<li>Data synchronization issues between clients: Check if the Network Identity components are set up correctly.<\/li>\n<li>Check for error messages: Review any error messages in the Unity Console and take necessary actions.<\/li>\n<\/ul>\n<h2>Conclusion<\/h2>\n<p>We have explored the basic ways to join a network room in Unity. Multiplayer games are complex, but understanding and utilizing basic functions is the start of success. In the next tutorial, we will cover more advanced features and techniques that can be used in real games, so stay tuned!<\/p>\n<footer>\n<p>If you have any questions or feedback regarding this article, please leave a comment. Thank you.<\/p>\n<\/footer>\n<p><\/body><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hello, everyone. In this tutorial, we will explore how to join a network room in Unity. Multiplayer game development is a very exciting and challenging field, and here we will understand the basic networking functions and explain step-by-step how to join a room. 1. Basics of Unity Networking Unity provides various networking solutions. The solution &hellip; <a href=\"https:\/\/atmokpo.com\/w\/32041\/\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;Unity Basic Course: Joining a Network Room&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[135],"tags":[],"class_list":["post-32041","post","type-post","status-publish","format-standard","hentry","category-unity-basic"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Unity Basic Course: Joining a Network Room - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/atmokpo.com\/w\/32041\/\" \/>\n<meta property=\"og:locale\" content=\"ko_KR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Unity Basic Course: Joining a Network Room - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"og:description\" content=\"Hello, everyone. In this tutorial, we will explore how to join a network room in Unity. Multiplayer game development is a very exciting and challenging field, and here we will understand the basic networking functions and explain step-by-step how to join a room. 1. Basics of Unity Networking Unity provides various networking solutions. The solution &hellip; \ub354 \ubcf4\uae30 &quot;Unity Basic Course: Joining a Network Room&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/atmokpo.com\/w\/32041\/\" \/>\n<meta property=\"og:site_name\" content=\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-01T09:05:12+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-01T11:33:34+00:00\" \/>\n<meta name=\"author\" content=\"root\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@bebubo4\" \/>\n<meta name=\"twitter:site\" content=\"@bebubo4\" \/>\n<meta name=\"twitter:label1\" content=\"\uae00\uc4f4\uc774\" \/>\n\t<meta name=\"twitter:data1\" content=\"root\" \/>\n\t<meta name=\"twitter:label2\" content=\"\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04\" \/>\n\t<meta name=\"twitter:data2\" content=\"3\ubd84\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/atmokpo.com\/w\/32041\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/32041\/\"},\"author\":{\"name\":\"root\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\"},\"headline\":\"Unity Basic Course: Joining a Network Room\",\"datePublished\":\"2024-11-01T09:05:12+00:00\",\"dateModified\":\"2024-11-01T11:33:34+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/atmokpo.com\/w\/32041\/\"},\"wordCount\":587,\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"articleSection\":[\"Unity Basic\"],\"inLanguage\":\"ko-KR\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/atmokpo.com\/w\/32041\/\",\"url\":\"https:\/\/atmokpo.com\/w\/32041\/\",\"name\":\"Unity Basic Course: Joining a Network Room - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#website\"},\"datePublished\":\"2024-11-01T09:05:12+00:00\",\"dateModified\":\"2024-11-01T11:33:34+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/atmokpo.com\/w\/32041\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/atmokpo.com\/w\/32041\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/atmokpo.com\/w\/32041\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\ud648\",\"item\":\"https:\/\/atmokpo.com\/w\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Unity Basic Course: Joining a Network Room\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/atmokpo.com\/w\/#website\",\"url\":\"https:\/\/atmokpo.com\/w\/\",\"name\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/atmokpo.com\/w\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"ko-KR\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\",\"name\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"url\":\"https:\/\/atmokpo.com\/w\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png\",\"contentUrl\":\"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png\",\"width\":400,\"height\":400,\"caption\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\"},\"image\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/bebubo4\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\",\"name\":\"root\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g\",\"caption\":\"root\"},\"sameAs\":[\"http:\/\/atmokpo.com\/w\"],\"url\":\"https:\/\/atmokpo.com\/w\/author\/root\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Unity Basic Course: Joining a Network Room - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/atmokpo.com\/w\/32041\/","og_locale":"ko_KR","og_type":"article","og_title":"Unity Basic Course: Joining a Network Room - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","og_description":"Hello, everyone. In this tutorial, we will explore how to join a network room in Unity. Multiplayer game development is a very exciting and challenging field, and here we will understand the basic networking functions and explain step-by-step how to join a room. 1. Basics of Unity Networking Unity provides various networking solutions. The solution &hellip; \ub354 \ubcf4\uae30 \"Unity Basic Course: Joining a Network Room\"","og_url":"https:\/\/atmokpo.com\/w\/32041\/","og_site_name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","article_published_time":"2024-11-01T09:05:12+00:00","article_modified_time":"2024-11-01T11:33:34+00:00","author":"root","twitter_card":"summary_large_image","twitter_creator":"@bebubo4","twitter_site":"@bebubo4","twitter_misc":{"\uae00\uc4f4\uc774":"root","\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04":"3\ubd84"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/atmokpo.com\/w\/32041\/#article","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/32041\/"},"author":{"name":"root","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7"},"headline":"Unity Basic Course: Joining a Network Room","datePublished":"2024-11-01T09:05:12+00:00","dateModified":"2024-11-01T11:33:34+00:00","mainEntityOfPage":{"@id":"https:\/\/atmokpo.com\/w\/32041\/"},"wordCount":587,"publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"articleSection":["Unity Basic"],"inLanguage":"ko-KR"},{"@type":"WebPage","@id":"https:\/\/atmokpo.com\/w\/32041\/","url":"https:\/\/atmokpo.com\/w\/32041\/","name":"Unity Basic Course: Joining a Network Room - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/#website"},"datePublished":"2024-11-01T09:05:12+00:00","dateModified":"2024-11-01T11:33:34+00:00","breadcrumb":{"@id":"https:\/\/atmokpo.com\/w\/32041\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/atmokpo.com\/w\/32041\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/atmokpo.com\/w\/32041\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\ud648","item":"https:\/\/atmokpo.com\/w\/en\/"},{"@type":"ListItem","position":2,"name":"Unity Basic Course: Joining a Network Room"}]},{"@type":"WebSite","@id":"https:\/\/atmokpo.com\/w\/#website","url":"https:\/\/atmokpo.com\/w\/","name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","description":"","publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/atmokpo.com\/w\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"ko-KR"},{"@type":"Organization","@id":"https:\/\/atmokpo.com\/w\/#organization","name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","url":"https:\/\/atmokpo.com\/w\/","logo":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/","url":"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png","contentUrl":"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png","width":400,"height":400,"caption":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8"},"image":{"@id":"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/bebubo4"]},{"@type":"Person","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7","name":"root","image":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g","caption":"root"},"sameAs":["http:\/\/atmokpo.com\/w"],"url":"https:\/\/atmokpo.com\/w\/author\/root\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/32041","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/comments?post=32041"}],"version-history":[{"count":1,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/32041\/revisions"}],"predecessor-version":[{"id":32042,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/32041\/revisions\/32042"}],"wp:attachment":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/media?parent=32041"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/categories?post=32041"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/tags?post=32041"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}