{"id":1117,"date":"2025-03-12T17:01:34","date_gmt":"2025-03-12T17:01:34","guid":{"rendered":"https:\/\/sites.wsagames.com\/et4g23\/?p=1117"},"modified":"2025-05-12T15:07:37","modified_gmt":"2025-05-12T15:07:37","slug":"player-week-4","status":"publish","type":"post","link":"https:\/\/sites.wsagames.com\/et4g23\/2025\/03\/12\/player-week-4\/","title":{"rendered":"Player &#8211; Pt 3"},"content":{"rendered":"\n<p class=\"has-text-align-center has-background\" style=\"background-color:#dfdfdf\">Throughout week 3 and the beginning of week 4, my time was spent finalising the Procedural Dungeon Generation and creating enemies to populate the depression realm. During this time our mechanics designer implemented an 8-directional attack, but it was up to me to implement health and damage to the player.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img fetchpriority=\"high\" decoding=\"async\" width=\"717\" height=\"524\" src=\"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/03\/image-106.png\" alt=\"\" class=\"wp-image-1340\" srcset=\"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/03\/image-106.png 717w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/03\/image-106-300x219.png 300w\" sizes=\"(max-width: 717px) 100vw, 717px\" \/><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\">Player Health Script<\/h2>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"971\" height=\"724\" src=\"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/03\/image-96.png\" alt=\"\" class=\"wp-image-1141\" srcset=\"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/03\/image-96.png 971w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/03\/image-96-300x224.png 300w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/03\/image-96-768x573.png 768w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/03\/image-96-850x634.png 850w\" sizes=\"(max-width: 971px) 100vw, 971px\" \/><\/figure>\n\n\n\n<p>This is a simple starter health script for the player, starting with public floats as numbers that correlate to the player&#8217;s max and current health count. With its current health being set to its max health in the Start() method.<\/p>\n\n\n\n<p>I wrote the <em><strong>TakeDamage(int damage<\/strong><\/em>) method to take in an int that will correlate to how much damage the player will take [shown as <em><strong>currentHealth -= damage<\/strong><\/em> which decreases the players current health by the int amount taken in by the TakeDamage method].  I did this as in the future there may be certain enemies or obstacles that deal more than 1 damage to the player, This is a much more robust method than the <strong><em>TakeDamage <\/em><\/strong>method having no input and dealing 1 damage to the player every time the method is called.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Making the player deal damage<\/h2>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p>In order to make the player deal damage, I created a similar <strong><em>TakeDamage() <\/em><\/strong>method in the enemy scripts, this method will exist in all enemies.<br>The <strong><em>roomManager.EnemyKilled(gameObject)<\/em><\/strong> part of the script is explained in the Dungeon section of this website.<\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"414\" height=\"221\" src=\"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/03\/image-97.png\" alt=\"\" class=\"wp-image-1142\" srcset=\"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/03\/image-97.png 414w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/03\/image-97-300x160.png 300w\" sizes=\"(max-width: 414px) 100vw, 414px\" \/><\/figure>\n<\/div>\n<\/div>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"887\" height=\"657\" src=\"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/03\/image-99.png\" alt=\"\" class=\"wp-image-1144\" srcset=\"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/03\/image-99.png 887w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/03\/image-99-300x222.png 300w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/03\/image-99-768x569.png 768w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/03\/image-99-850x630.png 850w\" sizes=\"(max-width: 887px) 100vw, 887px\" \/><\/figure>\n\n\n\n<p>Now that the enemies were able to take damage via the <strong><em>TakeDamage() <\/em><\/strong>method, I had to implement a way for that method to be called. This was done via the Weapon script I wrote above, this script would detect if the player&#8217;s melee&#8217;s BoxCollider2D component entered the enemies&#8217; BoxCollider2D component (It check this by checking the other collider&#8217;s tag, all enemies in the game are tagged with &#8220;Enemy&#8221;). If the melee&#8217;s trigger detected an enemy, it would then call the <em><strong>TakeDamage()<\/strong><\/em> method on that specific enemy&#8217;s script. As the damage int was set to 1 (<strong>public float damage = 1;<\/strong> Unity is able to convert floats without decimals to ints automatically), the enemy hit would then take 1 point of damage.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Player Dash<\/h2>\n\n\n\n<p>Once our Mechancis Designer, Ayse, had programmed a dash into the player movement, I needed to alter it slightly so that it would prevent the player from taking damage during this dash.<\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p>To do this, I changed the player&#8217;s PlayerHealth script and added an if statement to the <em><strong>TakeDamage() <\/strong><\/em>method.<\/p>\n\n\n\n<p>What this did was make the TakeDamage() method check if the player was dashing during a possible instance of damage, if the player was dashing, then no HP is deducted from the players currentHealth int.<\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\"><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"434\" height=\"402\" src=\"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/03\/image-108.png\" alt=\"\" class=\"wp-image-1343\" style=\"width:372px;height:auto\" srcset=\"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/03\/image-108.png 434w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/03\/image-108-300x278.png 300w\" sizes=\"(max-width: 434px) 100vw, 434px\" \/><\/figure><\/div><\/div>\n<\/div>\n\n\n\n<figure class=\"wp-block-video\"><video controls src=\"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/03\/Untitled-video-Made-with-Clipchamp-7-1.mp4\"><\/video><\/figure>\n\n\n\n<p>This video shows that in the console, the player&#8217;s health decreases while colliding with the enemy&#8217;s projectile. However, if it collides with it while dashing, the player&#8217;s health doesn&#8217;t decrease.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Throughout week 3 and the beginning of week 4, my time was spent finalising the Procedural Dungeon Generation and creating enemies to populate the depression realm. During this time our mechanics designer implemented an 8-directional attack, but it was up to me to implement health and damage to the player. Player Health Script This is&#8230;<\/p>\n","protected":false},"author":28,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1117","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Player - Pt 3 - E-Jay Tripoli (Year 2 Archive)<\/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:\/\/sites.wsagames.com\/et4g23\/2025\/03\/12\/player-week-4\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Player - Pt 3 - E-Jay Tripoli (Year 2 Archive)\" \/>\n<meta property=\"og:description\" content=\"Throughout week 3 and the beginning of week 4, my time was spent finalising the Procedural Dungeon Generation and creating enemies to populate the depression realm. During this time our mechanics designer implemented an 8-directional attack, but it was up to me to implement health and damage to the player. Player Health Script This is...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/sites.wsagames.com\/et4g23\/2025\/03\/12\/player-week-4\/\" \/>\n<meta property=\"og:site_name\" content=\"E-Jay Tripoli (Year 2 Archive)\" \/>\n<meta property=\"article:published_time\" content=\"2025-03-12T17:01:34+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-05-12T15:07:37+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/03\/image-106.png\" \/>\n<meta name=\"author\" content=\"et4g23\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"et4g23\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/sites.wsagames.com\/et4g23\/2025\/03\/12\/player-week-4\/\",\"url\":\"https:\/\/sites.wsagames.com\/et4g23\/2025\/03\/12\/player-week-4\/\",\"name\":\"Player - Pt 3 - E-Jay Tripoli (Year 2 Archive)\",\"isPartOf\":{\"@id\":\"https:\/\/sites.wsagames.com\/et4g23\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/sites.wsagames.com\/et4g23\/2025\/03\/12\/player-week-4\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/sites.wsagames.com\/et4g23\/2025\/03\/12\/player-week-4\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/03\/image-106.png\",\"datePublished\":\"2025-03-12T17:01:34+00:00\",\"dateModified\":\"2025-05-12T15:07:37+00:00\",\"author\":{\"@id\":\"https:\/\/sites.wsagames.com\/et4g23\/#\/schema\/person\/56387a1dc0de878bb33ce4c478f22963\"},\"breadcrumb\":{\"@id\":\"https:\/\/sites.wsagames.com\/et4g23\/2025\/03\/12\/player-week-4\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/sites.wsagames.com\/et4g23\/2025\/03\/12\/player-week-4\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/sites.wsagames.com\/et4g23\/2025\/03\/12\/player-week-4\/#primaryimage\",\"url\":\"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/03\/image-106.png\",\"contentUrl\":\"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/03\/image-106.png\",\"width\":717,\"height\":524},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/sites.wsagames.com\/et4g23\/2025\/03\/12\/player-week-4\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/sites.wsagames.com\/et4g23\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Player &#8211; Pt 3\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/sites.wsagames.com\/et4g23\/#website\",\"url\":\"https:\/\/sites.wsagames.com\/et4g23\/\",\"name\":\"E-Jay Tripoli (Year 2 Archive)\",\"description\":\"A documentation of my work for Year 2 - Studying Games Design and Art at the University of Southampton\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/sites.wsagames.com\/et4g23\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/sites.wsagames.com\/et4g23\/#\/schema\/person\/56387a1dc0de878bb33ce4c478f22963\",\"name\":\"et4g23\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/sites.wsagames.com\/et4g23\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/477d521b3b86e4ef27181bf784cd1a145a38c7d6a0154a478d3c858d26298bec?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/477d521b3b86e4ef27181bf784cd1a145a38c7d6a0154a478d3c858d26298bec?s=96&d=mm&r=g\",\"caption\":\"et4g23\"},\"url\":\"https:\/\/sites.wsagames.com\/et4g23\/author\/et4g23\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Player - Pt 3 - E-Jay Tripoli (Year 2 Archive)","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:\/\/sites.wsagames.com\/et4g23\/2025\/03\/12\/player-week-4\/","og_locale":"en_US","og_type":"article","og_title":"Player - Pt 3 - E-Jay Tripoli (Year 2 Archive)","og_description":"Throughout week 3 and the beginning of week 4, my time was spent finalising the Procedural Dungeon Generation and creating enemies to populate the depression realm. During this time our mechanics designer implemented an 8-directional attack, but it was up to me to implement health and damage to the player. Player Health Script This is...","og_url":"https:\/\/sites.wsagames.com\/et4g23\/2025\/03\/12\/player-week-4\/","og_site_name":"E-Jay Tripoli (Year 2 Archive)","article_published_time":"2025-03-12T17:01:34+00:00","article_modified_time":"2025-05-12T15:07:37+00:00","og_image":[{"url":"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/03\/image-106.png","type":"","width":"","height":""}],"author":"et4g23","twitter_card":"summary_large_image","twitter_misc":{"Written by":"et4g23","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/sites.wsagames.com\/et4g23\/2025\/03\/12\/player-week-4\/","url":"https:\/\/sites.wsagames.com\/et4g23\/2025\/03\/12\/player-week-4\/","name":"Player - Pt 3 - E-Jay Tripoli (Year 2 Archive)","isPartOf":{"@id":"https:\/\/sites.wsagames.com\/et4g23\/#website"},"primaryImageOfPage":{"@id":"https:\/\/sites.wsagames.com\/et4g23\/2025\/03\/12\/player-week-4\/#primaryimage"},"image":{"@id":"https:\/\/sites.wsagames.com\/et4g23\/2025\/03\/12\/player-week-4\/#primaryimage"},"thumbnailUrl":"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/03\/image-106.png","datePublished":"2025-03-12T17:01:34+00:00","dateModified":"2025-05-12T15:07:37+00:00","author":{"@id":"https:\/\/sites.wsagames.com\/et4g23\/#\/schema\/person\/56387a1dc0de878bb33ce4c478f22963"},"breadcrumb":{"@id":"https:\/\/sites.wsagames.com\/et4g23\/2025\/03\/12\/player-week-4\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/sites.wsagames.com\/et4g23\/2025\/03\/12\/player-week-4\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/sites.wsagames.com\/et4g23\/2025\/03\/12\/player-week-4\/#primaryimage","url":"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/03\/image-106.png","contentUrl":"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/03\/image-106.png","width":717,"height":524},{"@type":"BreadcrumbList","@id":"https:\/\/sites.wsagames.com\/et4g23\/2025\/03\/12\/player-week-4\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/sites.wsagames.com\/et4g23\/"},{"@type":"ListItem","position":2,"name":"Player &#8211; Pt 3"}]},{"@type":"WebSite","@id":"https:\/\/sites.wsagames.com\/et4g23\/#website","url":"https:\/\/sites.wsagames.com\/et4g23\/","name":"E-Jay Tripoli (Year 2 Archive)","description":"A documentation of my work for Year 2 - Studying Games Design and Art at the University of Southampton","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/sites.wsagames.com\/et4g23\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/sites.wsagames.com\/et4g23\/#\/schema\/person\/56387a1dc0de878bb33ce4c478f22963","name":"et4g23","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/sites.wsagames.com\/et4g23\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/477d521b3b86e4ef27181bf784cd1a145a38c7d6a0154a478d3c858d26298bec?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/477d521b3b86e4ef27181bf784cd1a145a38c7d6a0154a478d3c858d26298bec?s=96&d=mm&r=g","caption":"et4g23"},"url":"https:\/\/sites.wsagames.com\/et4g23\/author\/et4g23\/"}]}},"_links":{"self":[{"href":"https:\/\/sites.wsagames.com\/et4g23\/wp-json\/wp\/v2\/posts\/1117","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sites.wsagames.com\/et4g23\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sites.wsagames.com\/et4g23\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sites.wsagames.com\/et4g23\/wp-json\/wp\/v2\/users\/28"}],"replies":[{"embeddable":true,"href":"https:\/\/sites.wsagames.com\/et4g23\/wp-json\/wp\/v2\/comments?post=1117"}],"version-history":[{"count":7,"href":"https:\/\/sites.wsagames.com\/et4g23\/wp-json\/wp\/v2\/posts\/1117\/revisions"}],"predecessor-version":[{"id":1580,"href":"https:\/\/sites.wsagames.com\/et4g23\/wp-json\/wp\/v2\/posts\/1117\/revisions\/1580"}],"wp:attachment":[{"href":"https:\/\/sites.wsagames.com\/et4g23\/wp-json\/wp\/v2\/media?parent=1117"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sites.wsagames.com\/et4g23\/wp-json\/wp\/v2\/categories?post=1117"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sites.wsagames.com\/et4g23\/wp-json\/wp\/v2\/tags?post=1117"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}