{"id":31838,"date":"2024-11-01T09:03:22","date_gmt":"2024-11-01T09:03:22","guid":{"rendered":"http:\/\/atmokpo.com\/w\/?p=31838"},"modified":"2024-11-01T11:34:29","modified_gmt":"2024-11-01T11:34:29","slug":"unity-basic-course-restrictions-on-entering-playing-rooms","status":"publish","type":"post","link":"https:\/\/atmokpo.com\/w\/31838\/","title":{"rendered":"Unity Basic Course: Restrictions on Entering Playing Rooms"},"content":{"rendered":"<p><body><\/p>\n<p>In this tutorial, we will explain the &#8216;Room Entry Restriction&#8217; feature, which is one of the essential functions when developing multiplayer games in Unity. Through this tutorial, you will learn how to manage access to the game&#8217;s rooms. This feature plays a significant role in enhancing the quality of player experience across various genres, including blockchain games, MMORPGs, and FPS.<\/p>\n<h2>1. Before You Start<\/h2>\n<p>You need to understand the basic concepts of Unity and networking, as well as have a fundamental understanding of creating multiplayer games. In this tutorial, we will implement the room entry feature using <strong>Mirror Networking<\/strong>.<\/p>\n<h2>2. Setting Up Mirror Networking<\/h2>\n<h3>2.1. Installing Mirror<\/h3>\n<p>Mirror is an advanced networking library for Unity. Follow the steps below to install Mirror.<\/p>\n<ul>\n<li>Open Unity&#8217;s Package Manager.<\/li>\n<li>Add <code>https:\/\/github.com\/vis2k\/Mirror.git<\/code> in the Git URL.<\/li>\n<li>Install Mirror.<\/li>\n<\/ul>\n<h3>2.2. Basic Setup<\/h3>\n<p>After installing Mirror, you need to set up the following:<\/p>\n<ul>\n<li>Create a NetworkManager game object.<\/li>\n<li>Add the NetworkManager component.<\/li>\n<li>Add the NetworkManagerHUD component for easy UI setup.<\/li>\n<\/ul>\n<h2>3. Implementing Room Entry Restriction Logic<\/h2>\n<h3>3.1. Writing Room Creation Code<\/h3>\n<pre><code>using Mirror;\nusing UnityEngine;\n\npublic class RoomManager : NetworkBehaviour\n{\n    private int maxPlayers = 4; \/\/ Maximum number of players\n\n    public void CreateRoom()\n    {\n        if (NetworkServer.active) return;\n\n        var room = new GameObject(\"Room\");\n        NetworkServer.Spawn(room);\n    }\n}<\/code><\/pre>\n<h3>3.2. Implementing Room Entry Logic<\/h3>\n<p>You can check the maximum number of players in the room with the following code:<\/p>\n<pre><code>public class RoomManager : NetworkBehaviour\n{\n    private List<networkconnection> connections = new List<networkconnection>();\n\n    public override void OnServerAddPlayer(NetworkConnection conn)\n    {\n        if (connections.Count &gt;= maxPlayers)\n        {\n            conn.Disconnect(); \/\/ Disconnect if the number of players exceeds the maximum\n            return;\n        }\n        \n        base.OnServerAddPlayer(conn);\n        connections.Add(conn); \/\/ Add new player\n    }\n}<\/networkconnection><\/networkconnection><\/code><\/pre>\n<h2>4. Adding UI and Feedback<\/h2>\n<h3>4.1. Displaying the Number of Players<\/h3>\n<p>You can display the current number of players in the room through the UI. Create a Canvas and add a Text UI to show the number of connections in real-time.<\/p>\n<h3>4.2. Providing Feedback When Entry is Restricted<\/h3>\n<pre><code>if (connections.Count &gt;= maxPlayers)\n{\n    Debug.Log(\"The room is full, and no more players can enter.\");\n    \/\/ Provide additional UI feedback\n}<\/code><\/pre>\n<h2>5. Testing and Debugging<\/h2>\n<p>Now that the code and UI are ready, let&#8217;s test the multiplayer functionality in the Unity editor. Run each client and enter the room to debug and fix any errors more thoroughly.<\/p>\n<h2>6. Conclusion<\/h2>\n<p>In this tutorial, we learned how to implement the room entry restriction feature in Unity. These fundamental models in multiplayer games can greatly enhance the quality of player experience. We encourage you to challenge yourselves with better game development through various features and optimization work.<\/p>\n<h2>7. Additional Resources and References<\/h2>\n<ul>\n<li><a href=\"https:\/\/mirror-networking.com\/\">Official Mirror Networking Site<\/a><\/li>\n<li><a href=\"https:\/\/docs.unity3d.com\/Manual\/UNetSetup.html\">Unity UNet Documentation<\/a><\/li>\n<\/ul>\n<p><\/body><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, we will explain the &#8216;Room Entry Restriction&#8217; feature, which is one of the essential functions when developing multiplayer games in Unity. Through this tutorial, you will learn how to manage access to the game&#8217;s rooms. This feature plays a significant role in enhancing the quality of player experience across various genres, including &hellip; <a href=\"https:\/\/atmokpo.com\/w\/31838\/\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;Unity Basic Course: Restrictions on Entering Playing Rooms&#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-31838","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: Restrictions on Entering Playing Rooms - \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\/31838\/\" \/>\n<meta property=\"og:locale\" content=\"ko_KR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Unity Basic Course: Restrictions on Entering Playing Rooms - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"og:description\" content=\"In this tutorial, we will explain the &#8216;Room Entry Restriction&#8217; feature, which is one of the essential functions when developing multiplayer games in Unity. Through this tutorial, you will learn how to manage access to the game&#8217;s rooms. This feature plays a significant role in enhancing the quality of player experience across various genres, including &hellip; \ub354 \ubcf4\uae30 &quot;Unity Basic Course: Restrictions on Entering Playing Rooms&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/atmokpo.com\/w\/31838\/\" \/>\n<meta property=\"og:site_name\" content=\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-01T09:03:22+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-01T11:34:29+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=\"2\ubd84\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/atmokpo.com\/w\/31838\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/31838\/\"},\"author\":{\"name\":\"root\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\"},\"headline\":\"Unity Basic Course: Restrictions on Entering Playing Rooms\",\"datePublished\":\"2024-11-01T09:03:22+00:00\",\"dateModified\":\"2024-11-01T11:34:29+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/atmokpo.com\/w\/31838\/\"},\"wordCount\":335,\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"articleSection\":[\"Unity Basic\"],\"inLanguage\":\"ko-KR\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/atmokpo.com\/w\/31838\/\",\"url\":\"https:\/\/atmokpo.com\/w\/31838\/\",\"name\":\"Unity Basic Course: Restrictions on Entering Playing Rooms - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#website\"},\"datePublished\":\"2024-11-01T09:03:22+00:00\",\"dateModified\":\"2024-11-01T11:34:29+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/atmokpo.com\/w\/31838\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/atmokpo.com\/w\/31838\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/atmokpo.com\/w\/31838\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\ud648\",\"item\":\"https:\/\/atmokpo.com\/w\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Unity Basic Course: Restrictions on Entering Playing Rooms\"}]},{\"@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: Restrictions on Entering Playing Rooms - \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\/31838\/","og_locale":"ko_KR","og_type":"article","og_title":"Unity Basic Course: Restrictions on Entering Playing Rooms - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","og_description":"In this tutorial, we will explain the &#8216;Room Entry Restriction&#8217; feature, which is one of the essential functions when developing multiplayer games in Unity. Through this tutorial, you will learn how to manage access to the game&#8217;s rooms. This feature plays a significant role in enhancing the quality of player experience across various genres, including &hellip; \ub354 \ubcf4\uae30 \"Unity Basic Course: Restrictions on Entering Playing Rooms\"","og_url":"https:\/\/atmokpo.com\/w\/31838\/","og_site_name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","article_published_time":"2024-11-01T09:03:22+00:00","article_modified_time":"2024-11-01T11:34:29+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":"2\ubd84"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/atmokpo.com\/w\/31838\/#article","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/31838\/"},"author":{"name":"root","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7"},"headline":"Unity Basic Course: Restrictions on Entering Playing Rooms","datePublished":"2024-11-01T09:03:22+00:00","dateModified":"2024-11-01T11:34:29+00:00","mainEntityOfPage":{"@id":"https:\/\/atmokpo.com\/w\/31838\/"},"wordCount":335,"publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"articleSection":["Unity Basic"],"inLanguage":"ko-KR"},{"@type":"WebPage","@id":"https:\/\/atmokpo.com\/w\/31838\/","url":"https:\/\/atmokpo.com\/w\/31838\/","name":"Unity Basic Course: Restrictions on Entering Playing Rooms - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/#website"},"datePublished":"2024-11-01T09:03:22+00:00","dateModified":"2024-11-01T11:34:29+00:00","breadcrumb":{"@id":"https:\/\/atmokpo.com\/w\/31838\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/atmokpo.com\/w\/31838\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/atmokpo.com\/w\/31838\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\ud648","item":"https:\/\/atmokpo.com\/w\/en\/"},{"@type":"ListItem","position":2,"name":"Unity Basic Course: Restrictions on Entering Playing Rooms"}]},{"@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\/31838","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=31838"}],"version-history":[{"count":1,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/31838\/revisions"}],"predecessor-version":[{"id":31839,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/31838\/revisions\/31839"}],"wp:attachment":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/media?parent=31838"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/categories?post=31838"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/tags?post=31838"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}