{"id":31896,"date":"2024-11-01T09:03:58","date_gmt":"2024-11-01T09:03:58","guid":{"rendered":"http:\/\/atmokpo.com\/w\/?p=31896"},"modified":"2024-11-01T11:34:14","modified_gmt":"2024-11-01T11:34:14","slug":"unity-basic-course-vertical-rotation-of-the-view","status":"publish","type":"post","link":"https:\/\/atmokpo.com\/w\/31896\/","title":{"rendered":"Unity Basic Course: Vertical Rotation of the View"},"content":{"rendered":"<p>\n    Unity is a powerful engine for game development that provides the ability to create a variety of 2D and 3D applications.<br \/>\n    In this course, we will cover how to rotate the camera&#8217;s view up and down in Unity.<br \/>\n    Through this process, you will learn how to manipulate the player\u2019s viewpoint and, further, provide an immersive experience within the game.\n<\/p>\n<h2>1. Basic Setup<\/h2>\n<p>\n    First, launch Unity and create a new project.<br \/>\n    Select the 3D project and set an appropriate project name. After the project is launched, configure the basic scene.<br \/>\n    In the scene view, select the <strong>Main Camera<\/strong> object and adjust the camera&#8217;s position and rotation angles.<br \/>\n    The camera serves as the reference to display all game objects, so it must be properly set.\n<\/p>\n<h2>2. Setting Up the Camera and Player Character<\/h2>\n<p>\n    To set up the player character, select <strong>3D Object<\/strong> &gt; <strong>Cylinder<\/strong> from the <strong>GameObject<\/strong> menu to create a basic character model.<br \/>\n    This object will become a simple form of the player character. Rename the created cylinder to &#8216;Player&#8217;, and<br \/>\n    set the <strong>Main Camera<\/strong> as the child of the player.<br \/>\n    This will allow the camera to move with the player.\n<\/p>\n<h2>3. Setting Up the Input System<\/h2>\n<p>\n    To implement the up and down rotation of the camera, we will write a script for input processing. Create a folder named <strong>Scripts<\/strong> inside the <strong>Assets<\/strong> folder, and<br \/>\n    create a script named <strong>CameraController.cs<\/strong> within it.<br \/>\n    Paste the following code into the script:\n<\/p>\n<pre><code>\nusing System.Collections;\nusing System.Collections.Generic;\nusing UnityEngine;\n\npublic class CameraController : MonoBehaviour\n{\n    public Transform player; \/\/ Player character\n    public float sensitivity = 5.0f; \/\/ Mouse sensitivity\n    public float clampAngle = 80.0f; \/\/ Rotation limit angle\n\n    private float rotX = 0.0f; \/\/ Up and down rotation angle\n    private float rotY = 0.0f; \/\/ Left and right rotation angle\n\n    void Start()\n    {\n        rotX = transform.localEulerAngles.x; \/\/ Set initial up and down rotation angle\n        rotY = transform.localEulerAngles.y; \/\/ Set initial left and right rotation angle\n\n        Cursor.lockState = CursorLockMode.Locked; \/\/ Hide the mouse cursor\n    }\n\n    void Update()\n    {\n        rotX -= Input.GetAxis(\"Mouse Y\") * sensitivity; \/\/ Calculate up and down rotation with mouse Y input\n        rotY += Input.GetAxis(\"Mouse X\") * sensitivity; \/\/ Calculate left and right rotation with mouse X input\n\n        rotX = Mathf.Clamp(rotX, -clampAngle, clampAngle); \/\/ Limit the rotation angle\n\n        transform.localEulerAngles = new Vector3(rotX, rotY, 0); \/\/ Apply rotation\n        player.Rotate(0, Input.GetAxis(\"Mouse X\") * sensitivity, 0); \/\/ Apply left and right rotation to the player character\n    }\n}\n<\/code><\/pre>\n<p>\n    After writing the script, select the <strong>Main Camera<\/strong> object, click the <strong>Add Component<\/strong> button, and add the <strong>CameraController<\/strong> script you created.<br \/>\n    Then drag the <strong>Player<\/strong> object to the <strong>Player<\/strong> property of the <strong>CameraController<\/strong> script to link it.\n<\/p>\n<h2>4. Testing and Adjusting<\/h2>\n<p>\n    Now that all settings are complete, save the scene and click the play button to test the game.<br \/>\n    You can see the camera rotating up and down as you move the mouse, and the player character rotating left and right.<br \/>\n    If you want to adjust the sensitivity, you can change the value of the <strong>sensitivity<\/strong> variable to achieve your desired sensitivity.\n<\/p>\n<h2>5. Implementing Additional Features<\/h2>\n<p>\n    In addition to basic up and down rotation, you can add more diverse features to provide a better user experience.<br \/>\n    For example, you can use the <strong>SmoothDamp<\/strong> function to smooth the camera&#8217;s movement.\n<\/p>\n<pre><code>\nprivate Vector3 velocity = Vector3.zero; \/\/ Velocity variable\n\nvoid LateUpdate()\n{\n    Vector3 targetPosition = player.position; \/\/ Target position\n    transform.position = Vector3.SmoothDamp(transform.position, targetPosition, ref velocity, 0.3f); \/\/ Smooth camera movement\n}\n<\/code><\/pre>\n<p>\n    This shows how to smoothly move the camera considering the speed between frames using the <strong>LateUpdate<\/strong> method.<br \/>\n    This allows the camera to follow the player more naturally.\n<\/p>\n<h2>6. Conclusion<\/h2>\n<p>\n    Through this lecture, we learned the basic method for rotating the camera&#8217;s view up and down in Unity and how to manipulate the player\u2019s viewpoint.<br \/>\n    Based on this foundation, you can utilize it for various game design and implementation.<br \/>\n    Additionally, Unity offers many more features, so continuously learning and advancing is important.\n<\/p>\n<p>\n    In the future, we will cover various topics in the Unity beginner&#8217;s course series, so please stay tuned!<br \/>\n    Happy Coding!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Unity is a powerful engine for game development that provides the ability to create a variety of 2D and 3D applications. In this course, we will cover how to rotate the camera&#8217;s view up and down in Unity. Through this process, you will learn how to manipulate the player\u2019s viewpoint and, further, provide an immersive &hellip; <a href=\"https:\/\/atmokpo.com\/w\/31896\/\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;Unity Basic Course: Vertical Rotation of the View&#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-31896","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: Vertical Rotation of the View - \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\/31896\/\" \/>\n<meta property=\"og:locale\" content=\"ko_KR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Unity Basic Course: Vertical Rotation of the View - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"og:description\" content=\"Unity is a powerful engine for game development that provides the ability to create a variety of 2D and 3D applications. In this course, we will cover how to rotate the camera&#8217;s view up and down in Unity. Through this process, you will learn how to manipulate the player\u2019s viewpoint and, further, provide an immersive &hellip; \ub354 \ubcf4\uae30 &quot;Unity Basic Course: Vertical Rotation of the View&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/atmokpo.com\/w\/31896\/\" \/>\n<meta property=\"og:site_name\" content=\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-01T09:03:58+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-01T11:34:14+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\/31896\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/31896\/\"},\"author\":{\"name\":\"root\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\"},\"headline\":\"Unity Basic Course: Vertical Rotation of the View\",\"datePublished\":\"2024-11-01T09:03:58+00:00\",\"dateModified\":\"2024-11-01T11:34:14+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/atmokpo.com\/w\/31896\/\"},\"wordCount\":488,\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"articleSection\":[\"Unity Basic\"],\"inLanguage\":\"ko-KR\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/atmokpo.com\/w\/31896\/\",\"url\":\"https:\/\/atmokpo.com\/w\/31896\/\",\"name\":\"Unity Basic Course: Vertical Rotation of the View - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#website\"},\"datePublished\":\"2024-11-01T09:03:58+00:00\",\"dateModified\":\"2024-11-01T11:34:14+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/atmokpo.com\/w\/31896\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/atmokpo.com\/w\/31896\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/atmokpo.com\/w\/31896\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\ud648\",\"item\":\"https:\/\/atmokpo.com\/w\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Unity Basic Course: Vertical Rotation of the View\"}]},{\"@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: Vertical Rotation of the View - \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\/31896\/","og_locale":"ko_KR","og_type":"article","og_title":"Unity Basic Course: Vertical Rotation of the View - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","og_description":"Unity is a powerful engine for game development that provides the ability to create a variety of 2D and 3D applications. In this course, we will cover how to rotate the camera&#8217;s view up and down in Unity. Through this process, you will learn how to manipulate the player\u2019s viewpoint and, further, provide an immersive &hellip; \ub354 \ubcf4\uae30 \"Unity Basic Course: Vertical Rotation of the View\"","og_url":"https:\/\/atmokpo.com\/w\/31896\/","og_site_name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","article_published_time":"2024-11-01T09:03:58+00:00","article_modified_time":"2024-11-01T11:34:14+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\/31896\/#article","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/31896\/"},"author":{"name":"root","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7"},"headline":"Unity Basic Course: Vertical Rotation of the View","datePublished":"2024-11-01T09:03:58+00:00","dateModified":"2024-11-01T11:34:14+00:00","mainEntityOfPage":{"@id":"https:\/\/atmokpo.com\/w\/31896\/"},"wordCount":488,"publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"articleSection":["Unity Basic"],"inLanguage":"ko-KR"},{"@type":"WebPage","@id":"https:\/\/atmokpo.com\/w\/31896\/","url":"https:\/\/atmokpo.com\/w\/31896\/","name":"Unity Basic Course: Vertical Rotation of the View - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/#website"},"datePublished":"2024-11-01T09:03:58+00:00","dateModified":"2024-11-01T11:34:14+00:00","breadcrumb":{"@id":"https:\/\/atmokpo.com\/w\/31896\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/atmokpo.com\/w\/31896\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/atmokpo.com\/w\/31896\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\ud648","item":"https:\/\/atmokpo.com\/w\/en\/"},{"@type":"ListItem","position":2,"name":"Unity Basic Course: Vertical Rotation of the View"}]},{"@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\/31896","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=31896"}],"version-history":[{"count":1,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/31896\/revisions"}],"predecessor-version":[{"id":31897,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/31896\/revisions\/31897"}],"wp:attachment":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/media?parent=31896"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/categories?post=31896"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/tags?post=31896"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}