{"id":32083,"date":"2024-11-01T09:05:33","date_gmt":"2024-11-01T09:05:33","guid":{"rendered":"http:\/\/atmokpo.com\/w\/?p=32083"},"modified":"2024-11-01T11:33:22","modified_gmt":"2024-11-01T11:33:22","slug":"unity-basics-course-conditional-statements-else","status":"publish","type":"post","link":"https:\/\/atmokpo.com\/w\/32083\/","title":{"rendered":"Unity Basics Course: Conditional Statements &#8211; else"},"content":{"rendered":"<p><body><\/p>\n<article>\n<p>\n            Unity is a very powerful and flexible engine for game development. A basic understanding of programming languages is essential to understand the systematic flow of game development. In this course, we will take a closer look at one of the fundamental concepts of programming: conditional statements, particularly the &#8216;else&#8217; statement.\n        <\/p>\n<section>\n<h2>1. Basics of Conditional Statements<\/h2>\n<p>\n                Conditional statements are used to control the flow of a program based on certain conditions. The most common form is the &#8216;if&#8217; statement. The &#8216;if&#8217; statement defines a block of code that executes when the condition is true. However, if you want to perform different actions when the condition is false, the &#8216;else&#8217; statement is used. The &#8216;else&#8217; statement is used alongside the &#8216;if&#8217; statement to help handle complex conditions.\n            <\/p>\n<\/section>\n<section>\n<h2>2. Basic Structure of &#8216;else&#8217; Statement<\/h2>\n<p>\n                The &#8216;else&#8217; statement has the following structure:<\/p>\n<pre>\n                if (condition) {\n                    \/\/ Code to execute if the condition is true\n                } else {\n                    \/\/ Code to execute if the condition is false\n                }\n                <\/pre>\n<p>In the example above, the &#8216;if&#8217; statement evaluates the condition, and based on the result, different code blocks are executed.<\/p>\n<\/p>\n<\/section>\n<section>\n<h2>3. Example Usage of &#8216;else&#8217; Statement<\/h2>\n<p>\n                Let&#8217;s see an example of using the &#8216;else&#8217; statement in actual Unity code. Below is a simple example that outputs messages based on the player&#8217;s score:<\/p>\n<pre>\n                void Update() {\n                    int score = 10; \/\/ Player's score\n                    if (score >= 20) {\n                        Debug.Log(\"Score is 20 or more!\");\n                    } else {\n                        Debug.Log(\"Score is less than 20.\");\n                    }\n                }\n                <\/pre>\n<p>In the code above, different messages are printed depending on whether the player&#8217;s score is 20 or more or not. By using the &#8216;else&#8217; statement in this way, you can implement various actions based on conditions.<\/p>\n<\/p>\n<\/section>\n<section>\n<h2>4. Compound Conditional Statements and &#8216;else if&#8217;<\/h2>\n<p>\n                The &#8216;else&#8217; statement is very useful for handling compound conditions as it is used with the &#8216;if&#8217; statement. Using the &#8216;else if&#8217; statement allows you to check additional conditions. Here is an example:<\/p>\n<pre>\n                void Update() {\n                    int score = 15;\n                    if (score >= 20) {\n                        Debug.Log(\"Score is 20 or more!\");\n                    } else if (score >= 10) {\n                        Debug.Log(\"Score is 10 or more.\");\n                    } else {\n                        Debug.Log(\"Score is less than 10.\");\n                    }\n                }\n                <\/pre>\n<p>This code handles three cases based on the score. Only the block for the true condition will execute, allowing for multiple condition branching using &#8216;else if&#8217;.<\/p>\n<\/p>\n<\/section>\n<section>\n<h2>5. Use Cases for Conditional Statements<\/h2>\n<p>\n                Below is an example of a conditional statement that can be useful in a game. This example assumes a situation where the accessible area is determined based on the player&#8217;s character&#8217;s state:<\/p>\n<pre>\n                bool hasKey = false; \/\/ Whether the player has the key\n                void Update() {\n                    if (hasKey) {\n                        Debug.Log(\"You can enter here because you have the key.\");\n                    } else {\n                        Debug.Log(\"You need a key!\");\n                    }\n                }\n                <\/pre>\n<p>In this way, conditional statements become a powerful tool for controlling various situations within a game.<\/p>\n<\/p>\n<\/section>\n<section>\n<h2>6. Optimization and Considerations for Conditional Statements<\/h2>\n<p>\n                When using a lot of conditional statements, the code can become complex and inefficient. Here are some points to consider when using conditional statements:<\/p>\n<ul>\n<li>Avoid nesting multiple conditional statements. Complex nesting decreases readability and makes maintenance difficult.<\/li>\n<li>Express conditions clearly. If the conditions are complex, write them so that their meaning is easily understandable.<\/li>\n<\/ul>\n<\/section>\n<section>\n<h2>7. Conclusion<\/h2>\n<p>\n                The &#8216;else&#8217; statement plays an important role in Unity programming and is an essential tool for controlling the flow and actions of the game. Through this course, I hope you understand the basic usage of conditional statements and apply them in actual game development. By effectively utilizing conditional statements, you can create very diverse game logic.\n            <\/p>\n<\/section>\n<\/article>\n<p><\/body><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Unity is a very powerful and flexible engine for game development. A basic understanding of programming languages is essential to understand the systematic flow of game development. In this course, we will take a closer look at one of the fundamental concepts of programming: conditional statements, particularly the &#8216;else&#8217; statement. 1. Basics of Conditional Statements &hellip; <a href=\"https:\/\/atmokpo.com\/w\/32083\/\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;Unity Basics Course: Conditional Statements &#8211; else&#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-32083","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: Conditional Statements - else - \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\/32083\/\" \/>\n<meta property=\"og:locale\" content=\"ko_KR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Unity Basics Course: Conditional Statements - else - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"og:description\" content=\"Unity is a very powerful and flexible engine for game development. A basic understanding of programming languages is essential to understand the systematic flow of game development. In this course, we will take a closer look at one of the fundamental concepts of programming: conditional statements, particularly the &#8216;else&#8217; statement. 1. Basics of Conditional Statements &hellip; \ub354 \ubcf4\uae30 &quot;Unity Basics Course: Conditional Statements &#8211; else&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/atmokpo.com\/w\/32083\/\" \/>\n<meta property=\"og:site_name\" content=\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-01T09:05:33+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-01T11:33:22+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\/32083\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/32083\/\"},\"author\":{\"name\":\"root\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\"},\"headline\":\"Unity Basics Course: Conditional Statements &#8211; else\",\"datePublished\":\"2024-11-01T09:05:33+00:00\",\"dateModified\":\"2024-11-01T11:33:22+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/atmokpo.com\/w\/32083\/\"},\"wordCount\":469,\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"articleSection\":[\"Unity Basic\"],\"inLanguage\":\"ko-KR\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/atmokpo.com\/w\/32083\/\",\"url\":\"https:\/\/atmokpo.com\/w\/32083\/\",\"name\":\"Unity Basics Course: Conditional Statements - else - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#website\"},\"datePublished\":\"2024-11-01T09:05:33+00:00\",\"dateModified\":\"2024-11-01T11:33:22+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/atmokpo.com\/w\/32083\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/atmokpo.com\/w\/32083\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/atmokpo.com\/w\/32083\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\ud648\",\"item\":\"https:\/\/atmokpo.com\/w\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Unity Basics Course: Conditional Statements &#8211; else\"}]},{\"@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: Conditional Statements - else - \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\/32083\/","og_locale":"ko_KR","og_type":"article","og_title":"Unity Basics Course: Conditional Statements - else - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","og_description":"Unity is a very powerful and flexible engine for game development. A basic understanding of programming languages is essential to understand the systematic flow of game development. In this course, we will take a closer look at one of the fundamental concepts of programming: conditional statements, particularly the &#8216;else&#8217; statement. 1. Basics of Conditional Statements &hellip; \ub354 \ubcf4\uae30 \"Unity Basics Course: Conditional Statements &#8211; else\"","og_url":"https:\/\/atmokpo.com\/w\/32083\/","og_site_name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","article_published_time":"2024-11-01T09:05:33+00:00","article_modified_time":"2024-11-01T11:33:22+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\/32083\/#article","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/32083\/"},"author":{"name":"root","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7"},"headline":"Unity Basics Course: Conditional Statements &#8211; else","datePublished":"2024-11-01T09:05:33+00:00","dateModified":"2024-11-01T11:33:22+00:00","mainEntityOfPage":{"@id":"https:\/\/atmokpo.com\/w\/32083\/"},"wordCount":469,"publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"articleSection":["Unity Basic"],"inLanguage":"ko-KR"},{"@type":"WebPage","@id":"https:\/\/atmokpo.com\/w\/32083\/","url":"https:\/\/atmokpo.com\/w\/32083\/","name":"Unity Basics Course: Conditional Statements - else - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/#website"},"datePublished":"2024-11-01T09:05:33+00:00","dateModified":"2024-11-01T11:33:22+00:00","breadcrumb":{"@id":"https:\/\/atmokpo.com\/w\/32083\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/atmokpo.com\/w\/32083\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/atmokpo.com\/w\/32083\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\ud648","item":"https:\/\/atmokpo.com\/w\/en\/"},{"@type":"ListItem","position":2,"name":"Unity Basics Course: Conditional Statements &#8211; else"}]},{"@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\/32083","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=32083"}],"version-history":[{"count":1,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/32083\/revisions"}],"predecessor-version":[{"id":32084,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/32083\/revisions\/32084"}],"wp:attachment":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/media?parent=32083"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/categories?post=32083"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/tags?post=32083"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}