{"id":31815,"date":"2024-11-01T09:03:11","date_gmt":"2024-11-01T09:03:11","guid":{"rendered":"http:\/\/atmokpo.com\/w\/?p=31815"},"modified":"2024-11-01T11:34:35","modified_gmt":"2024-11-01T11:34:35","slug":"unity-basics-course-following-the-player-character","status":"publish","type":"post","link":"https:\/\/atmokpo.com\/w\/31815\/","title":{"rendered":"Unity Basics Course: Following the Player Character"},"content":{"rendered":"<p><body><\/p>\n<p>Hello! In this tutorial, we will learn in detail how to create an enemy character that chases the player character using Unity. Understanding character movement and AI (Moving AI), which are fundamental elements of game development, will be very helpful. This tutorial will be explained step by step so that beginners who are not familiar with Unity can follow along.<\/p>\n<h2>Table of Contents<\/h2>\n<ul>\n<li><a href=\"#section1\">1. Installing Unity and Setting Up the Project<\/a><\/li>\n<li><a href=\"#section2\">2. Creating the Player Character<\/a><\/li>\n<li><a href=\"#section3\">3. Creating the Enemy Character<\/a><\/li>\n<li><a href=\"#section4\">4. Writing the Tracking Script for the Enemy Character<\/a><\/li>\n<li><a href=\"#section5\">5. Testing and Optimization<\/a><\/li>\n<li><a href=\"#section6\">6. Conclusion<\/a><\/li>\n<\/ul>\n<h2 id=\"section1\">1. Installing Unity and Setting Up the Project<\/h2>\n<p>First, let&#8217;s install Unity and create a new 3D project. Please download and install Unity Hub from the official Unity website, then follow these steps.<\/p>\n<ol>\n<li>Run Unity Hub and click the <strong>New Project<\/strong> button.<\/li>\n<li>Enter a name for the project, select the <strong>3D<\/strong> template, and then click the <strong>Create<\/strong> button.<\/li>\n<li>Once the project is created, the basic scene environment will appear.<\/li>\n<\/ol>\n<h2 id=\"section2\">2. Creating the Player Character<\/h2>\n<p>To create the player character, we will use basic 3D objects. We will proceed with the following steps.<\/p>\n<ol>\n<li>Right-click in the Hierarchy window and select <strong>3D Object &gt; Capsule<\/strong>. We will use this as the player character.<\/li>\n<li>Adjust the Transform component of the Capsule to set an appropriate size.<\/li>\n<li>In the Inspector window, click the <strong>Add Component<\/strong> button and add a <strong>Rigidbody<\/strong> to apply gravity.<\/li>\n<li>Also, set the character to touch the ground using a <strong>Collider<\/strong>.<\/li>\n<\/ol>\n<h2 id=\"section3\">3. Creating the Enemy Character<\/h2>\n<p>Now let&#8217;s add the enemy character. The enemy character can also be created using a 3D object.<\/p>\n<ol>\n<li>Right-click in the Hierarchy window again and select <strong>3D Object &gt; Cube<\/strong> to create the enemy character.<\/li>\n<li>Adjust the Transform component of the Cube to set the size and position of the enemy character.<\/li>\n<li>Add a Rigidbody component to the enemy to enable physical interactions.<\/li>\n<\/ol>\n<h2 id=\"section4\">4. Writing the Tracking Script for the Enemy Character<\/h2>\n<p>Now let&#8217;s write a script to allow the enemy character to track the player. Here\u2019s an example of a C# script.<\/p>\n<pre><code>using UnityEngine;\n\npublic class EnemyController : MonoBehaviour\n{\n    public Transform player; \/\/ Player's Transform\n    public float speed = 2.0f; \/\/ Speed of the enemy character\n    public float detectionRange = 5.0f; \/\/ Range within which the enemy can chase\n\n    void Update()\n    {\n        \/\/ Calculate distance to the player\n        float distance = Vector3.Distance(transform.position, player.position);\n        \n        \/\/ Move towards the player if within range\n        if (distance &lt; detectionRange)\n        {\n            Vector3 direction = (player.position - transform.position).normalized;\n            transform.position += direction * speed * Time.deltaTime;\n        }\n    }\n}\n<\/code><\/pre>\n<p>Using the code above, set up the enemy character to chase the player. Attach the script to the enemy character object and drag the player character into the <strong>player<\/strong> field to add it.<\/p>\n<h2 id=\"section5\">5. Testing and Optimization<\/h2>\n<p>Now that everything is set up, run the game in play mode to check if the enemy character chases the player properly.<\/p>\n<p>You should also consider performance optimization. As the number of enemies increases, avoid simply having all enemies chase the player; consider additional logic to limit the number of enemies that chase.<\/p>\n<h2 id=\"section6\">6. Conclusion<\/h2>\n<p>In this tutorial, we learned how to implement an enemy character that chases the player character using Unity. In this process, we created basic 3D objects and wrote scripts to implement game AI. These fundamental elements will serve as a basis for creating more complex game logic.<\/p>\n<p>Continue to learn more features through various Unity tutorials in the future. Thank you!<\/p>\n<p><\/body><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hello! In this tutorial, we will learn in detail how to create an enemy character that chases the player character using Unity. Understanding character movement and AI (Moving AI), which are fundamental elements of game development, will be very helpful. This tutorial will be explained step by step so that beginners who are not familiar &hellip; <a href=\"https:\/\/atmokpo.com\/w\/31815\/\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;Unity Basics Course: Following the Player Character&#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-31815","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: Following the Player Character - \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\/31815\/\" \/>\n<meta property=\"og:locale\" content=\"ko_KR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Unity Basics Course: Following the Player Character - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"og:description\" content=\"Hello! In this tutorial, we will learn in detail how to create an enemy character that chases the player character using Unity. Understanding character movement and AI (Moving AI), which are fundamental elements of game development, will be very helpful. This tutorial will be explained step by step so that beginners who are not familiar &hellip; \ub354 \ubcf4\uae30 &quot;Unity Basics Course: Following the Player Character&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/atmokpo.com\/w\/31815\/\" \/>\n<meta property=\"og:site_name\" content=\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-01T09:03:11+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-01T11:34:35+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\/31815\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/31815\/\"},\"author\":{\"name\":\"root\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\"},\"headline\":\"Unity Basics Course: Following the Player Character\",\"datePublished\":\"2024-11-01T09:03:11+00:00\",\"dateModified\":\"2024-11-01T11:34:35+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/atmokpo.com\/w\/31815\/\"},\"wordCount\":495,\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"articleSection\":[\"Unity Basic\"],\"inLanguage\":\"ko-KR\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/atmokpo.com\/w\/31815\/\",\"url\":\"https:\/\/atmokpo.com\/w\/31815\/\",\"name\":\"Unity Basics Course: Following the Player Character - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#website\"},\"datePublished\":\"2024-11-01T09:03:11+00:00\",\"dateModified\":\"2024-11-01T11:34:35+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/atmokpo.com\/w\/31815\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/atmokpo.com\/w\/31815\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/atmokpo.com\/w\/31815\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\ud648\",\"item\":\"https:\/\/atmokpo.com\/w\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Unity Basics Course: Following the Player Character\"}]},{\"@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: Following the Player Character - \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\/31815\/","og_locale":"ko_KR","og_type":"article","og_title":"Unity Basics Course: Following the Player Character - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","og_description":"Hello! In this tutorial, we will learn in detail how to create an enemy character that chases the player character using Unity. Understanding character movement and AI (Moving AI), which are fundamental elements of game development, will be very helpful. This tutorial will be explained step by step so that beginners who are not familiar &hellip; \ub354 \ubcf4\uae30 \"Unity Basics Course: Following the Player Character\"","og_url":"https:\/\/atmokpo.com\/w\/31815\/","og_site_name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","article_published_time":"2024-11-01T09:03:11+00:00","article_modified_time":"2024-11-01T11:34:35+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\/31815\/#article","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/31815\/"},"author":{"name":"root","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7"},"headline":"Unity Basics Course: Following the Player Character","datePublished":"2024-11-01T09:03:11+00:00","dateModified":"2024-11-01T11:34:35+00:00","mainEntityOfPage":{"@id":"https:\/\/atmokpo.com\/w\/31815\/"},"wordCount":495,"publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"articleSection":["Unity Basic"],"inLanguage":"ko-KR"},{"@type":"WebPage","@id":"https:\/\/atmokpo.com\/w\/31815\/","url":"https:\/\/atmokpo.com\/w\/31815\/","name":"Unity Basics Course: Following the Player Character - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/#website"},"datePublished":"2024-11-01T09:03:11+00:00","dateModified":"2024-11-01T11:34:35+00:00","breadcrumb":{"@id":"https:\/\/atmokpo.com\/w\/31815\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/atmokpo.com\/w\/31815\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/atmokpo.com\/w\/31815\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\ud648","item":"https:\/\/atmokpo.com\/w\/en\/"},{"@type":"ListItem","position":2,"name":"Unity Basics Course: Following the Player Character"}]},{"@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\/31815","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=31815"}],"version-history":[{"count":1,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/31815\/revisions"}],"predecessor-version":[{"id":31816,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/31815\/revisions\/31816"}],"wp:attachment":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/media?parent=31815"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/categories?post=31815"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/tags?post=31815"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}