{"id":31846,"date":"2024-11-01T09:03:26","date_gmt":"2024-11-01T09:03:26","guid":{"rendered":"http:\/\/atmokpo.com\/w\/?p=31846"},"modified":"2024-11-01T11:34:27","modified_gmt":"2024-11-01T11:34:27","slug":"unity-basics-course-camera-and-alignment","status":"publish","type":"post","link":"https:\/\/atmokpo.com\/w\/31846\/","title":{"rendered":"Unity Basics Course: Camera and Alignment"},"content":{"rendered":"<p>Today, we will conduct an in-depth tutorial on cameras and alignment in Unity. This tutorial covers content that can be useful for beginners to intermediate developers, detailing the essential camera manipulation methods and the theory and practice of alignment when developing games and applications in Unity.<\/p>\n<h2>1. Understanding Unity Cameras<\/h2>\n<p>Cameras play a very important role in Unity. The camera represents the player&#8217;s viewpoint in the game world and is a key element in determining the visual experience of the game. Unity&#8217;s default camera provides various options to set clips, field of view, position, rotation, and more in 3D space.<\/p>\n<h3>1.1 Types of Cameras<\/h3>\n<ul>\n<li><strong>Perspective Camera:<\/strong> Primarily used in 3D games, it provides a sense of depth.<\/li>\n<li><strong>Orthographic Camera:<\/strong> Used in 2D games, it displays all objects at the same scale.<\/li>\n<\/ul>\n<h3>1.2 Key Properties of the Camera<\/h3>\n<p>The main properties of the Unity camera include the following:<\/p>\n<ul>\n<li><strong>Field of View (FOV):<\/strong> Sets the camera&#8217;s viewing angle. A wider FOV shows more information at once, while a narrower FOV provides a more focused view.<\/li>\n<li><strong>Clipping Planes:<\/strong> The distance of objects that the camera can visually show. The Near Clip Plane sets the minimum distance between the camera and the object, while the Far Clip Plane sets the maximum distance.<\/li>\n<li><strong>Background Color:<\/strong> Sets the background color of the camera.<\/li>\n<\/ul>\n<h2>2. Creating and Setting Up the Camera<\/h2>\n<p>The process of creating a camera in Unity is very simple. Follow the steps below:<\/p>\n<h3>2.1 Creating the Camera<\/h3>\n<ol>\n<li>Select <strong>GameObject &gt; Camera<\/strong> from the Unity Editor menu.<\/li>\n<li>A new camera object will be created in the Hierarchy view.<\/li>\n<\/ol>\n<h3>2.2 Adjusting Camera Position and Rotation<\/h3>\n<p>To change the position and rotation of the created camera, do the following:<\/p>\n<ol>\n<li>Select the camera object in the Hierarchy.<\/li>\n<li>In the Inspector window, find the <strong>Transform<\/strong> component and adjust the <strong>Position<\/strong> and <strong>Rotation<\/strong> values.<\/li>\n<\/ol>\n<h3>2.3 Adjusting Camera Properties<\/h3>\n<p>In the Inspector window, set the camera&#8217;s FOV, Clipping Planes, Background Color, etc., to determine the visual style of the game.<\/p>\n<h2>3. Scripts for the Camera<\/h2>\n<p>In Unity, you can write scripts in C# to control the camera&#8217;s behavior. For example, let&#8217;s write a script to have the camera follow the player&#8217;s movement.<\/p>\n<h3>3.1 Writing the Script<\/h3>\n<p>You can write a basic camera-following script like the following:<\/p>\n<pre><code>\nusing UnityEngine;\n\npublic class CameraFollow : MonoBehaviour\n{\n    public Transform target; \/\/ The target to follow\n    public float smoothSpeed = 0.125f; \/\/ Smooth movement speed\n    public Vector3 offset; \/\/ Position offset\n\n    void LateUpdate()\n    {\n        Vector3 desiredPosition = target.position + offset;\n        Vector3 smoothedPosition = Vector3.Lerp(transform.position, desiredPosition, smoothSpeed);\n        transform.position = smoothedPosition;\n    }\n}\n<\/code><\/pre>\n<h3>3.2 Applying the Script<\/h3>\n<ol>\n<li>Right-click in the Assets folder, select <strong>Create &gt; C# Script<\/strong>, and name it <em>CameraFollow<\/em>.<\/li>\n<li>Copy and paste the above code.<\/li>\n<li>Select the camera object, click the <strong>Add Component<\/strong> button, and add the <em>CameraFollow<\/em> script.<\/li>\n<li>Drag and drop the player object into the <strong>Target<\/strong> field to set it.<\/li>\n<li>Adjust the Offset value to set the gap between the camera and the player.<\/li>\n<\/ol>\n<h2>4. The Importance of Alignment<\/h2>\n<p>In games, alignment refers to the process of ensuring that the player&#8217;s viewpoint and the character&#8217;s direction match. This significantly enhances the immersion of gameplay and contributes to improving the user&#8217;s experience.<\/p>\n<h3>4.1 Scripts for Alignment<\/h3>\n<p>To make the character face the direction of movement when the player moves, you can write a script as follows:<\/p>\n<pre><code>\nusing UnityEngine;\n\npublic class PlayerMovement : MonoBehaviour\n{\n    public float moveSpeed = 5f;\n\n    void Update()\n    {\n        float horizontal = Input.GetAxis(\"Horizontal\");\n        float vertical = Input.GetAxis(\"Vertical\");\n        Vector3 direction = new Vector3(horizontal, 0f, vertical).normalized;\n\n        if (direction.magnitude >= 0.1f)\n        {\n            float targetAngle = Mathf.Atan2(direction.x, direction.z) * Mathf.Rad2Deg;\n            transform.rotation = Quaternion.Euler(0f, targetAngle, 0f);\n            transform.position += direction * moveSpeed * Time.deltaTime;\n        }\n    }\n}\n<\/code><\/pre>\n<h2>5. Practice: Integrating the Camera and Alignment<\/h2>\n<p>Based on what we have learned so far, let&#8217;s integrate the camera and alignment to create simple character controls.<\/p>\n<h3>5.1 Preparing the Character Model<\/h3>\n<p>Import the character model into the Unity Editor and add it to the Hierarchy view. Adjust the position and rotation of the character model to place it appropriately.<\/p>\n<h3>5.2 Connecting the Camera and Character<\/h3>\n<p>Add the previously written <em>CameraFollow<\/em> script to the camera and set the target to the character model. This will allow the camera to follow the character.<\/p>\n<h3>5.3 Applying the Character Script<\/h3>\n<p>Also add the <em>PlayerMovement<\/em> script to the character model to set the player&#8217;s movement and alignment.<\/p>\n<h2>6. Conclusion<\/h2>\n<p>In this tutorial, we learned how to create and set up a camera in Unity, how to write a camera-following script, and how to implement basic movements in the game through the character alignment script. This foundational knowledge is essential for developing games in Unity and will serve as a solid basis for progressing to the next steps.<\/p>\n<p>If you have any additional questions or need help, please leave a comment. I hope your experience with Unity contributes to achieving good results. Thank you!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today, we will conduct an in-depth tutorial on cameras and alignment in Unity. This tutorial covers content that can be useful for beginners to intermediate developers, detailing the essential camera manipulation methods and the theory and practice of alignment when developing games and applications in Unity. 1. Understanding Unity Cameras Cameras play a very important &hellip; <a href=\"https:\/\/atmokpo.com\/w\/31846\/\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;Unity Basics Course: Camera and Alignment&#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-31846","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: Camera and Alignment - \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\/31846\/\" \/>\n<meta property=\"og:locale\" content=\"ko_KR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Unity Basics Course: Camera and Alignment - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"og:description\" content=\"Today, we will conduct an in-depth tutorial on cameras and alignment in Unity. This tutorial covers content that can be useful for beginners to intermediate developers, detailing the essential camera manipulation methods and the theory and practice of alignment when developing games and applications in Unity. 1. Understanding Unity Cameras Cameras play a very important &hellip; \ub354 \ubcf4\uae30 &quot;Unity Basics Course: Camera and Alignment&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/atmokpo.com\/w\/31846\/\" \/>\n<meta property=\"og:site_name\" content=\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-01T09:03:26+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-01T11:34:27+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\/31846\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/31846\/\"},\"author\":{\"name\":\"root\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\"},\"headline\":\"Unity Basics Course: Camera and Alignment\",\"datePublished\":\"2024-11-01T09:03:26+00:00\",\"dateModified\":\"2024-11-01T11:34:27+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/atmokpo.com\/w\/31846\/\"},\"wordCount\":700,\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"articleSection\":[\"Unity Basic\"],\"inLanguage\":\"ko-KR\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/atmokpo.com\/w\/31846\/\",\"url\":\"https:\/\/atmokpo.com\/w\/31846\/\",\"name\":\"Unity Basics Course: Camera and Alignment - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#website\"},\"datePublished\":\"2024-11-01T09:03:26+00:00\",\"dateModified\":\"2024-11-01T11:34:27+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/atmokpo.com\/w\/31846\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/atmokpo.com\/w\/31846\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/atmokpo.com\/w\/31846\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\ud648\",\"item\":\"https:\/\/atmokpo.com\/w\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Unity Basics Course: Camera and Alignment\"}]},{\"@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: Camera and Alignment - \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\/31846\/","og_locale":"ko_KR","og_type":"article","og_title":"Unity Basics Course: Camera and Alignment - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","og_description":"Today, we will conduct an in-depth tutorial on cameras and alignment in Unity. This tutorial covers content that can be useful for beginners to intermediate developers, detailing the essential camera manipulation methods and the theory and practice of alignment when developing games and applications in Unity. 1. Understanding Unity Cameras Cameras play a very important &hellip; \ub354 \ubcf4\uae30 \"Unity Basics Course: Camera and Alignment\"","og_url":"https:\/\/atmokpo.com\/w\/31846\/","og_site_name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","article_published_time":"2024-11-01T09:03:26+00:00","article_modified_time":"2024-11-01T11:34:27+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\/31846\/#article","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/31846\/"},"author":{"name":"root","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7"},"headline":"Unity Basics Course: Camera and Alignment","datePublished":"2024-11-01T09:03:26+00:00","dateModified":"2024-11-01T11:34:27+00:00","mainEntityOfPage":{"@id":"https:\/\/atmokpo.com\/w\/31846\/"},"wordCount":700,"publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"articleSection":["Unity Basic"],"inLanguage":"ko-KR"},{"@type":"WebPage","@id":"https:\/\/atmokpo.com\/w\/31846\/","url":"https:\/\/atmokpo.com\/w\/31846\/","name":"Unity Basics Course: Camera and Alignment - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/#website"},"datePublished":"2024-11-01T09:03:26+00:00","dateModified":"2024-11-01T11:34:27+00:00","breadcrumb":{"@id":"https:\/\/atmokpo.com\/w\/31846\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/atmokpo.com\/w\/31846\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/atmokpo.com\/w\/31846\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\ud648","item":"https:\/\/atmokpo.com\/w\/en\/"},{"@type":"ListItem","position":2,"name":"Unity Basics Course: Camera and Alignment"}]},{"@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\/31846","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=31846"}],"version-history":[{"count":1,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/31846\/revisions"}],"predecessor-version":[{"id":31847,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/31846\/revisions\/31847"}],"wp:attachment":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/media?parent=31846"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/categories?post=31846"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/tags?post=31846"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}