{"id":31773,"date":"2024-11-01T09:02:44","date_gmt":"2024-11-01T09:02:44","guid":{"rendered":"http:\/\/atmokpo.com\/w\/?p=31773"},"modified":"2024-11-01T11:34:47","modified_gmt":"2024-11-01T11:34:47","slug":"unity-basics-course-network-environment-and-photon-application","status":"publish","type":"post","link":"https:\/\/atmokpo.com\/w\/31773\/","title":{"rendered":"Unity Basics Course: Network Environment and Photon Application"},"content":{"rendered":"<p><body><\/p>\n<h2>1. What is Unity?<\/h2>\n<p>Unity is a powerful engine for developing video games and simulation software. It helps create games that can run on various platforms in both 2D and 3D environments. One of the main features of Unity is its intuitive user interface and robust scripting capabilities, allowing developers to easily prototype and create high-quality games.<\/p>\n<h2>2. Understanding Network Environments<\/h2>\n<p>When developing a game, especially if you want to create a multiplayer game, it is crucial to understand the network environment. The network environment is a system that manages data communication between clients and servers, determining how game data is transmitted and synchronized.<\/p>\n<h3>2.1 Client-Server Model<\/h3>\n<p>The client-server model is fundamentally a structure that divides into clients and servers. The client provides the user interface, while the server processes the client&#8217;s requests and manages the data. In multiplayer games, multiple clients connect to a single server and exchange data.<\/p>\n<h3>2.2 Peer-to-Peer Model<\/h3>\n<p>The Peer-to-Peer (P2P) model has all participants at the same level of authority and is structured for direct data exchange. This model does not require a server; however, it is generally not used due to network stability and security issues.<\/p>\n<h3>2.3 Synchronization Issues<\/h3>\n<p>In multiplayer games, data synchronization is critical. For instance, one player&#8217;s movements must be immediately reflected to other players. To achieve this, the server must manage this information and ensure correct data transmission between clients.<\/p>\n<h2>3. Introduction to Photon<\/h2>\n<p>Photon is a very popular networking engine for real-time multiplayer games. Photon offers a cloud-based solution, making it easy to implement multiplayer functionality. Using Photon allows you to create games that multiple players can access simultaneously without the need to manage a server directly.<\/p>\n<h3>3.1 Features of Photon<\/h3>\n<p>Photon provides the following advantages:<\/p>\n<ul>\n<li>Real-time data transmission: Data transfer between clients is very fast.<\/li>\n<li>Flexible server structure: The server is managed in the cloud, so there are no additional server costs.<\/li>\n<li>Support for various platforms: Photon can be easily adapted to different platforms such as Unity, iOS, Android, and WebGL.<\/li>\n<\/ul>\n<h2>4. Using Photon in Unity<\/h2>\n<p>Now let&#8217;s explore how to implement multiplayer functionality using Photon in Unity. The process of integrating Photon into Unity is as follows.<\/p>\n<h3>4.1 Installing Photon SDK<\/h3>\n<p>To use Photon, you first need to install the Photon Unity Networking (PUN) SDK. You can search for &#8220;Photon Unity Networking&#8221; in the Unity Asset Store and download it for free. Once installed, it will be automatically added to the Plugins folder of your Unity project.<\/p>\n<h3>4.2 Creating a Photon Account<\/h3>\n<p>To utilize Photon&#8217;s cloud services, you need to create a free account on the Photon website. After creating an account, you will receive an App ID. This App ID is necessary for using Photon in Unity, so make sure to copy it.<\/p>\n<h3>4.3 Initializing Photon<\/h3>\n<p>To use Photon in Unity, you need initialization code. Here is a simple example of initialization code:<\/p>\n<pre><code>using Photon.Pun;\n\n    public class NetworkManager : MonoBehaviourPunCallbacks\n    {\n        void Start()\n        {\n            PhotonNetwork.ConnectUsingSettings();\n        }\n\n        public override void OnConnectedToMaster()\n        {\n            Debug.Log(\"Connected to server.\");\n        }\n    }<\/code><\/pre>\n<h3>4.4 Creating and Joining Rooms<\/h3>\n<p>In Photon, you create Rooms and allow other players to find them. The code for creating a room is as follows:<\/p>\n<pre><code>void CreateRoom()\n    {\n        RoomOptions roomOptions = new RoomOptions();\n        roomOptions.MaxPlayers = 10; \/\/ Maximum number of players\n        PhotonNetwork.CreateRoom(\"Room1\", roomOptions, null);\n    }<\/code><\/pre>\n<h3>4.5 Player Spawning<\/h3>\n<p>Every time a player joins a room, you need to instantiate that player in the scene. To do this, use the following code:<\/p>\n<pre><code>public GameObject playerPrefab;\n\n    public override void OnJoinedRoom()\n    {\n        GameObject player = PhotonNetwork.Instantiate(playerPrefab.name, Vector3.zero, Quaternion.identity, 0);\n    }<\/code><\/pre>\n<h2>5. Multiplayer Game Example<\/h2>\n<p>Now let\u2019s take a look at a simple multiplayer game example. In this game, two players can control each other.<\/p>\n<h3>5.1 Creating a Player Controller<\/h3>\n<p>Write a script that handles player movement. Here is a basic code for player movement:<\/p>\n<pre><code>using Photon.Pun;\n    using UnityEngine;\n\n    public class PlayerController : MonoBehaviourPun\n    {\n        void Update()\n        {\n            if (photonView.IsMine)\n            {\n                MovePlayer();\n            }\n        }\n\n        void MovePlayer()\n        {\n            float moveHorizontal = Input.GetAxis(\"Horizontal\");\n            float moveVertical = Input.GetAxis(\"Vertical\");\n\n            Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);\n            transform.Translate(movement * Time.deltaTime * 5f);\n        }\n    }<\/code><\/pre>\n<h3>5.2 Adding UI<\/h3>\n<p>Incorporate UI elements into the game to guide players in creating and joining rooms. Using Unity&#8217;s Canvas system, you can add buttons and implement room creation and joining functionalities when the buttons are clicked.<\/p>\n<h2>6. Conclusion<\/h2>\n<p>This tutorial provided an introductory method for creating multiplayer games in Unity and setting up networking using Photon. Photon offers relatively easy and robust features, making it a very useful tool for developers looking to create multiplayer games. Furthermore, continue studying advanced techniques and gain experience in diverse game development.<\/p>\n<h2>7. Additional Learning Resources<\/h2>\n<p>You can gain deeper knowledge through additional resources about Unity and Photon:<\/p>\n<ul>\n<li><a href=\"https:\/\/unity.com\/\">Official Unity Website<\/a><\/li>\n<li><a href=\"https:\/\/www.photonengine.com\/en-US\/PUN\">Official Documentation for Photon Unity Networking<\/a><\/li>\n<li><a href=\"https:\/\/www.udemy.com\/topic\/unity\/\">Online Courses related to Unity<\/a><\/li>\n<\/ul>\n<p><\/body><\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. What is Unity? Unity is a powerful engine for developing video games and simulation software. It helps create games that can run on various platforms in both 2D and 3D environments. One of the main features of Unity is its intuitive user interface and robust scripting capabilities, allowing developers to easily prototype and create &hellip; <a href=\"https:\/\/atmokpo.com\/w\/31773\/\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;Unity Basics Course: Network Environment and Photon Application&#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-31773","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 Basics Course: Network Environment and Photon Application - \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\/31773\/\" \/>\n<meta property=\"og:locale\" content=\"ko_KR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Unity Basics Course: Network Environment and Photon Application - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"og:description\" content=\"1. What is Unity? Unity is a powerful engine for developing video games and simulation software. It helps create games that can run on various platforms in both 2D and 3D environments. One of the main features of Unity is its intuitive user interface and robust scripting capabilities, allowing developers to easily prototype and create &hellip; \ub354 \ubcf4\uae30 &quot;Unity Basics Course: Network Environment and Photon Application&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/atmokpo.com\/w\/31773\/\" \/>\n<meta property=\"og:site_name\" content=\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-01T09:02:44+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-01T11:34:47+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=\"4\ubd84\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/atmokpo.com\/w\/31773\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/31773\/\"},\"author\":{\"name\":\"root\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\"},\"headline\":\"Unity Basics Course: Network Environment and Photon Application\",\"datePublished\":\"2024-11-01T09:02:44+00:00\",\"dateModified\":\"2024-11-01T11:34:47+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/atmokpo.com\/w\/31773\/\"},\"wordCount\":690,\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"articleSection\":[\"Unity Basic\"],\"inLanguage\":\"ko-KR\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/atmokpo.com\/w\/31773\/\",\"url\":\"https:\/\/atmokpo.com\/w\/31773\/\",\"name\":\"Unity Basics Course: Network Environment and Photon Application - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#website\"},\"datePublished\":\"2024-11-01T09:02:44+00:00\",\"dateModified\":\"2024-11-01T11:34:47+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/atmokpo.com\/w\/31773\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/atmokpo.com\/w\/31773\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/atmokpo.com\/w\/31773\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\ud648\",\"item\":\"https:\/\/atmokpo.com\/w\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Unity Basics Course: Network Environment and Photon Application\"}]},{\"@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 Basics Course: Network Environment and Photon Application - \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\/31773\/","og_locale":"ko_KR","og_type":"article","og_title":"Unity Basics Course: Network Environment and Photon Application - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","og_description":"1. What is Unity? Unity is a powerful engine for developing video games and simulation software. It helps create games that can run on various platforms in both 2D and 3D environments. One of the main features of Unity is its intuitive user interface and robust scripting capabilities, allowing developers to easily prototype and create &hellip; \ub354 \ubcf4\uae30 \"Unity Basics Course: Network Environment and Photon Application\"","og_url":"https:\/\/atmokpo.com\/w\/31773\/","og_site_name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","article_published_time":"2024-11-01T09:02:44+00:00","article_modified_time":"2024-11-01T11:34:47+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":"4\ubd84"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/atmokpo.com\/w\/31773\/#article","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/31773\/"},"author":{"name":"root","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7"},"headline":"Unity Basics Course: Network Environment and Photon Application","datePublished":"2024-11-01T09:02:44+00:00","dateModified":"2024-11-01T11:34:47+00:00","mainEntityOfPage":{"@id":"https:\/\/atmokpo.com\/w\/31773\/"},"wordCount":690,"publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"articleSection":["Unity Basic"],"inLanguage":"ko-KR"},{"@type":"WebPage","@id":"https:\/\/atmokpo.com\/w\/31773\/","url":"https:\/\/atmokpo.com\/w\/31773\/","name":"Unity Basics Course: Network Environment and Photon Application - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/#website"},"datePublished":"2024-11-01T09:02:44+00:00","dateModified":"2024-11-01T11:34:47+00:00","breadcrumb":{"@id":"https:\/\/atmokpo.com\/w\/31773\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/atmokpo.com\/w\/31773\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/atmokpo.com\/w\/31773\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\ud648","item":"https:\/\/atmokpo.com\/w\/en\/"},{"@type":"ListItem","position":2,"name":"Unity Basics Course: Network Environment and Photon Application"}]},{"@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\/31773","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=31773"}],"version-history":[{"count":1,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/31773\/revisions"}],"predecessor-version":[{"id":31774,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/31773\/revisions\/31774"}],"wp:attachment":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/media?parent=31773"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/categories?post=31773"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/tags?post=31773"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}