{"id":32091,"date":"2024-11-01T09:05:37","date_gmt":"2024-11-01T09:05:37","guid":{"rendered":"http:\/\/atmokpo.com\/w\/?p=32091"},"modified":"2024-11-01T11:33:20","modified_gmt":"2024-11-01T11:33:20","slug":"unity-basics-course-adding-player-movement-feature","status":"publish","type":"post","link":"https:\/\/atmokpo.com\/w\/32091\/","title":{"rendered":"Unity Basics Course: Adding Player Movement Feature"},"content":{"rendered":"<p><body><\/p>\n<p>Hello! In this tutorial, we will learn how to develop a simple player movement function using Unity. Unity is a powerful engine that allows the development of various games and applications, and it is a preferred platform for many developers. This tutorial is aimed at those with a basic understanding of Unity, and it will be explained in detail so that beginner developers can easily follow along.<\/p>\n<h2>1. Project Setup<\/h2>\n<p>When starting with Unity for the first time, it is important to set up the project. Let&#8217;s create a new 3D project following the steps below.<\/p>\n<ol>\n<li>Open Unity Hub and click the <strong>New Project<\/strong> button.<\/li>\n<li>Select <strong>3D<\/strong> as the project type.<\/li>\n<li>Name the project \u201cPlayerMovement\u201d and click the <strong>Create<\/strong> button.<\/li>\n<\/ol>\n<p>Once the project is created, the main editor screen will open. Here, you can create scenes and add game objects.<\/p>\n<h2>2. Setting Up the Scene<\/h2>\n<p>Now, let&#8217;s set up a basic scene. We will add a 3D object, a cube, and modify it to create a player character.<\/p>\n<h3>2.1 Adding a Cube<\/h3>\n<p>To add a cube, follow these steps:<\/p>\n<ol>\n<li>Right-click in the Hierarchy window and select <strong>3D Object<\/strong> &gt; <strong>Cube<\/strong>.<\/li>\n<li>Once the cube is created, adjust the cube&#8217;s <strong>Transform<\/strong> settings in the Inspector window to change its position (for example, set it to <code>(0, 0.5, 0)<\/code>).<\/li>\n<\/ol>\n<h3>2.2 Setting Up the Camera<\/h3>\n<p>Adjust the camera position so that the player can see the cube clearly:<\/p>\n<ol>\n<li>Select the Main Camera object in the Hierarchy.<\/li>\n<li>Set the Transform&#8217;s Position in the Inspector to <code>(0, 2, -5)<\/code>.<\/li>\n<li>Set the Camera&#8217;s Rotation to <code>(15, 0, 0)<\/code> so that it faces the cube.<\/li>\n<\/ol>\n<h2>3. Creating the Player Movement Script<\/h2>\n<p>Now, let&#8217;s add a script to allow the player to move. The process of creating and attaching the script to a game object is as follows.<\/p>\n<h3>3.1 Generating the Script<\/h3>\n<ol>\n<li>Right-click on the <strong>Assets<\/strong> folder in the Project window and select <strong>Create<\/strong> &gt; <strong>C# Script<\/strong>.<\/li>\n<li>Name the script <code>PlayerController<\/code>.<\/li>\n<\/ol>\n<h3>3.2 Writing the Script Content<\/h3>\n<p>Now, open the <code>PlayerController.cs<\/code> file and enter the following code:<\/p>\n<pre><code>using System.Collections;\nusing System.Collections.Generic;\nusing UnityEngine;\n\npublic class PlayerController : MonoBehaviour\n{\n    public float moveSpeed = 5.0f;\n\n    void Update()\n    {\n        float horizontal = Input.GetAxis(\"Horizontal\");\n        float vertical = Input.GetAxis(\"Vertical\");\n\n        Vector3 direction = new Vector3(horizontal, 0, vertical);\n        transform.Translate(direction * moveSpeed * Time.deltaTime, Space.World);\n    }\n}\n<\/code><\/pre>\n<h3>3.3 Attaching the Script<\/h3>\n<p>Attach the created script to the cube (player object):<\/p>\n<ol>\n<li>Select the cube in the Hierarchy.<\/li>\n<li>Click the <strong>Add Component<\/strong> button in the Inspector and search for <code>PlayerController<\/code> to add it.<\/li>\n<\/ol>\n<h2>4. Testing Player Movement<\/h2>\n<p>Now that all the settings are complete, follow the steps below to test if the player can move:<\/p>\n<ol>\n<li>Click <strong>File<\/strong> &gt; <strong>Save<\/strong> in the top menu to save the scene.<\/li>\n<li>Click the <strong>Play<\/strong> button in the top menu to run the game.<\/li>\n<li>Try moving the player using the arrow keys or WASD keys on the keyboard.<\/li>\n<\/ol>\n<h2>5. Implementing Additional Features<\/h2>\n<p>Having just the basic movement feature may not make the game interesting. Therefore, let\u2019s add more features.<\/p>\n<h3>5.1 Adding a Jump Feature<\/h3>\n<p>Now, let&#8217;s add a jump feature. To do this, we need to use the physics engine. In this example, we will add a Rigidbody component to the cube as a collider, and implement the jump feature in the script.<\/p>\n<pre><code>void Start()\n{\n    rb = GetComponent<rigidbody>();\n}\n\nvoid Update()\n{\n    ...\n    if (Input.GetKeyDown(KeyCode.Space) &amp;&amp; isGrounded)\n    {\n        rb.AddForce(Vector3.up * jumpForce, ForceMode.Impulse);\n    }\n}\n<\/code><\/pre>\n<h3>5.2 Interacting with Obstacles<\/h3>\n<p>To enable the player to interact with obstacles, collision detection can be implemented. For example, you can add functionality that increases the score when the player reaches a target or collects an item.<\/p>\n<h2>6. Final Testing and Improvements<\/h2>\n<p>After confirming that all features work correctly, consider adding elements that enhance the fun of the game. For instance, you could improve the graphics or add background music.<\/p>\n<h2>7. Conclusion<\/h2>\n<p>Today, we learned how to implement player movement functionality in Unity. Based on this basic knowledge, continue to add more features and improve your game. You can become a better developer through practice. Thank you!<\/p>\n<h2>8. References<\/h2>\n<p>The official Unity documentation and community forums are excellent resources for learning. If needed, visit the following links to find more information:<\/p>\n<ul>\n<li><a href=\"https:\/\/docs.unity3d.com\/Manual\/index.html\">Unity Manual<\/a><\/li>\n<li><a href=\"https:\/\/forum.unity.com\/\">Unity Forum<\/a><\/li>\n<\/ul>\n<p><\/body><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hello! In this tutorial, we will learn how to develop a simple player movement function using Unity. Unity is a powerful engine that allows the development of various games and applications, and it is a preferred platform for many developers. This tutorial is aimed at those with a basic understanding of Unity, and it will &hellip; <a href=\"https:\/\/atmokpo.com\/w\/32091\/\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;Unity Basics Course: Adding Player Movement Feature&#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-32091","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: Adding Player Movement Feature - \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\/32091\/\" \/>\n<meta property=\"og:locale\" content=\"ko_KR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Unity Basics Course: Adding Player Movement Feature - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"og:description\" content=\"Hello! In this tutorial, we will learn how to develop a simple player movement function using Unity. Unity is a powerful engine that allows the development of various games and applications, and it is a preferred platform for many developers. This tutorial is aimed at those with a basic understanding of Unity, and it will &hellip; \ub354 \ubcf4\uae30 &quot;Unity Basics Course: Adding Player Movement Feature&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/atmokpo.com\/w\/32091\/\" \/>\n<meta property=\"og:site_name\" content=\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-01T09:05:37+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-01T11:33:20+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\/32091\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/32091\/\"},\"author\":{\"name\":\"root\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\"},\"headline\":\"Unity Basics Course: Adding Player Movement Feature\",\"datePublished\":\"2024-11-01T09:05:37+00:00\",\"dateModified\":\"2024-11-01T11:33:20+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/atmokpo.com\/w\/32091\/\"},\"wordCount\":619,\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"articleSection\":[\"Unity Basic\"],\"inLanguage\":\"ko-KR\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/atmokpo.com\/w\/32091\/\",\"url\":\"https:\/\/atmokpo.com\/w\/32091\/\",\"name\":\"Unity Basics Course: Adding Player Movement Feature - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#website\"},\"datePublished\":\"2024-11-01T09:05:37+00:00\",\"dateModified\":\"2024-11-01T11:33:20+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/atmokpo.com\/w\/32091\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/atmokpo.com\/w\/32091\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/atmokpo.com\/w\/32091\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\ud648\",\"item\":\"https:\/\/atmokpo.com\/w\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Unity Basics Course: Adding Player Movement Feature\"}]},{\"@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: Adding Player Movement Feature - \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\/32091\/","og_locale":"ko_KR","og_type":"article","og_title":"Unity Basics Course: Adding Player Movement Feature - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","og_description":"Hello! In this tutorial, we will learn how to develop a simple player movement function using Unity. Unity is a powerful engine that allows the development of various games and applications, and it is a preferred platform for many developers. This tutorial is aimed at those with a basic understanding of Unity, and it will &hellip; \ub354 \ubcf4\uae30 \"Unity Basics Course: Adding Player Movement Feature\"","og_url":"https:\/\/atmokpo.com\/w\/32091\/","og_site_name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","article_published_time":"2024-11-01T09:05:37+00:00","article_modified_time":"2024-11-01T11:33:20+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\/32091\/#article","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/32091\/"},"author":{"name":"root","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7"},"headline":"Unity Basics Course: Adding Player Movement Feature","datePublished":"2024-11-01T09:05:37+00:00","dateModified":"2024-11-01T11:33:20+00:00","mainEntityOfPage":{"@id":"https:\/\/atmokpo.com\/w\/32091\/"},"wordCount":619,"publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"articleSection":["Unity Basic"],"inLanguage":"ko-KR"},{"@type":"WebPage","@id":"https:\/\/atmokpo.com\/w\/32091\/","url":"https:\/\/atmokpo.com\/w\/32091\/","name":"Unity Basics Course: Adding Player Movement Feature - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/#website"},"datePublished":"2024-11-01T09:05:37+00:00","dateModified":"2024-11-01T11:33:20+00:00","breadcrumb":{"@id":"https:\/\/atmokpo.com\/w\/32091\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/atmokpo.com\/w\/32091\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/atmokpo.com\/w\/32091\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\ud648","item":"https:\/\/atmokpo.com\/w\/en\/"},{"@type":"ListItem","position":2,"name":"Unity Basics Course: Adding Player Movement Feature"}]},{"@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\/32091","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=32091"}],"version-history":[{"count":1,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/32091\/revisions"}],"predecessor-version":[{"id":32092,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/32091\/revisions\/32092"}],"wp:attachment":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/media?parent=32091"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/categories?post=32091"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/tags?post=32091"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}