{"id":1179,"date":"2025-05-09T18:37:34","date_gmt":"2025-05-09T18:37:34","guid":{"rendered":"https:\/\/sites.wsagames.com\/et4g23\/?p=1179"},"modified":"2025-05-09T19:44:14","modified_gmt":"2025-05-09T19:44:14","slug":"player-pt-4","status":"publish","type":"post","link":"https:\/\/sites.wsagames.com\/et4g23\/2025\/05\/09\/player-pt-4\/","title":{"rendered":"Player &#8211; Pt 4"},"content":{"rendered":"\n<p class=\"has-text-align-center has-background\" style=\"background-color:#dfdfdf\">When developing the Player character further, we had noticed a lot of bugs and issues during this process, this post outlines our discussions, decisions and what I had to do in order to fix them.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Outlining Issues and Changes<\/h2>\n\n\n\n<p>Firstly, when Ayse, our Mechanics Designer pushed her initial version of the Player with its new attack, I noticed two issues: It was able to move around with the attack hit box activated and The player could hold left-click and the attack hitbox would constantly be active. Which caused me to do the following:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img fetchpriority=\"high\" decoding=\"async\" width=\"793\" height=\"139\" src=\"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-10.png\" alt=\"\" class=\"wp-image-1181\" srcset=\"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-10.png 793w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-10-300x53.png 300w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-10-768x135.png 768w\" sizes=\"(max-width: 793px) 100vw, 793px\" \/><\/figure><\/div>\n\n\n<p>However, neither me nor our Mechanics Designer was unable to find a way around these two issues:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"350\" src=\"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-11-1024x350.png\" alt=\"\" class=\"wp-image-1182\" srcset=\"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-11-1024x350.png 1024w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-11-300x103.png 300w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-11-768x263.png 768w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-11-850x291.png 850w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-11.png 1117w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Which resulted in me suggesting to re-do the player entirely for a few reasons:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"533\" src=\"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-12-1024x533.png\" alt=\"\" class=\"wp-image-1183\" srcset=\"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-12-1024x533.png 1024w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-12-300x156.png 300w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-12-768x400.png 768w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-12-850x443.png 850w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-12.png 1104w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>After explaining my though process, our Mechanics Designer also agreed it would be best for me to re-do the player entirely:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"397\" src=\"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-14-1024x397.png\" alt=\"\" class=\"wp-image-1185\" srcset=\"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-14-1024x397.png 1024w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-14-300x116.png 300w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-14-768x298.png 768w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-14-850x330.png 850w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-14.png 1449w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Fixing the Player<\/h2>\n\n\n\n<p>In order to fix the player, I had to re-do it entirely. Therefore, I not only had to recreate some existing features, I also needed to fix issues and bugs that occurred with the previous iteration of the player:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Reduce the amount of attack directions the player had from 8 to 4\n<ul class=\"wp-block-list\">\n<li>(Reduce the workload on our animator)<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Make the players&#8217; position locked while attacking\n<ul class=\"wp-block-list\">\n<li>(The player was able to move while attacking in the previous version)<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Can dash during attack<\/li>\n\n\n\n<li>Play the correct animation when the player attacked<\/li>\n\n\n\n<li>Deactivate the attack hitbox after a duration<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"364\" src=\"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-15-1024x364.png\" alt=\"\" class=\"wp-image-1186\" srcset=\"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-15-1024x364.png 1024w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-15-300x107.png 300w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-15-768x273.png 768w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-15-850x302.png 850w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-15.png 1239w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">My GitHub commit to the lament repository, fixing the player<\/figcaption><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\">Attack<\/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\" style=\"flex-basis:66.66%\">\n<p>Firstly, the function of the player that was causing the most issues was its <strong>attack<\/strong>, so this was the part I decided to tackle first. To begin, I created four separate hit boxes for its attack, one of which would activate when the player pressed left-click, depending on what <strong><em>direction<\/em><\/strong> the player was facing (Explained in the <strong>Movement <\/strong>section below).<\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:33.33%\"><div class=\"wp-block-image\">\n<figure data-wp-context=\"{&quot;imageId&quot;:&quot;6a06da8abb541&quot;}\" data-wp-interactive=\"core\/image\" class=\"aligncenter size-full is-resized wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"501\" height=\"476\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-16.png\" alt=\"\" class=\"wp-image-1187\" style=\"width:186px;height:auto\" srcset=\"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-16.png 501w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-16-300x285.png 300w\" sizes=\"(max-width: 501px) 100vw, 501px\" \/><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\taria-label=\"Enlarge\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on-async--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.imageButtonRight\"\n\t\t\tdata-wp-style--top=\"state.imageButtonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewBox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><\/div>\n<\/div>\n\n\n\n<p>To implement this logic, I created a new C# script called AttackNew:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"860\" src=\"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-17-1024x860.png\" alt=\"\" class=\"wp-image-1188\" srcset=\"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-17-1024x860.png 1024w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-17-300x252.png 300w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-17-768x645.png 768w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-17-850x713.png 850w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-17.png 1046w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>This script had references to all of the player&#8217;s attack hitboxes e.g: <em><strong>public GameObject upMelee;<\/strong><\/em> and other variables for the attack, such as: <em><strong>public float atkDuration = 0.5f;<\/strong><\/em> , <em><strong>public bool isAttacking = false;<\/strong><\/em> , <em><strong>Animator anim<\/strong><\/em> etc.<\/p>\n\n\n\n<p>In the <em><strong>Start()<\/strong><\/em> method, some of these references are gotten, like the player&#8217;s controller script and animator.<\/p>\n\n\n\n<p>The <em><strong>Update()<\/strong><\/em> method is constantly calling the <em><strong>CheckMeleeTimer() <\/strong><\/em>method and checking if the player has pressed left-click, if they have and the player isn&#8217;t attacking, the <em><strong>HandleAttack() <\/strong><\/em>method is called.<\/p>\n\n\n\n<p>This <strong><em>HandleAttack() <\/em><\/strong>method, sets the <em><strong>isAttacking animator bool <\/strong><\/em>to true, which can then be used in Unity&#8217;s animator to play the correct attack animation, it then starts the<em><strong> MeleeActive() coroutine <\/strong><\/em>and sets the <em><strong>isAttacking bool <\/strong><\/em>to true.<br>This <em><strong>MeleeActive() coroutine <\/strong><\/em>waits a small duration (For the windup of the attack animation) and then activates one of the melee hitboxes depending on what direction the player is facing. Then, after another small duration, the hitbox is set to inactive and the <em><strong>isAttacking bool <\/strong><\/em>and <em><strong>isAttacking animator bool <\/strong><\/em>is set to<em><strong> false <\/strong><\/em>aswell. To prevent the attack animation from being played and allowing the player to attack again.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Movement<\/h2>\n\n\n\n<p>Although I created a new C# script called PlayerControllerNew, the majority of it is kept the same from its previous iteration, such as its: Player movement, inputs and dash. However, one of the only differences is that this script stores what direction the player is currently facing:<\/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>In order to do this, I created 4 bools under the heading of &#8220;FacingDirection&#8221;, only one of these bools would ever be active at once, essentially storing which direction the player was facing.<\/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 loading=\"lazy\" decoding=\"async\" width=\"519\" height=\"168\" src=\"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-18.png\" alt=\"\" class=\"wp-image-1189\" srcset=\"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-18.png 519w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-18-300x97.png 300w\" sizes=\"(max-width: 519px) 100vw, 519px\" \/><\/figure>\n<\/div>\n<\/div>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"454\" src=\"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-19-1024x454.png\" alt=\"\" class=\"wp-image-1190\" srcset=\"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-19-1024x454.png 1024w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-19-300x133.png 300w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-19-768x340.png 768w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-19-850x377.png 850w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-19.png 1420w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>In order to set these bools, I created a <em><strong>SetFacingDirection(bool right, bool left, bool up, bool down) <\/strong><\/em>method, which would take in input of 4 separate bools, each corresponding to a direction that the player could be facing.<\/p>\n\n\n\n<p>Then, in the <em><strong>ProcessInputs()<\/strong><\/em> method of the PlayerControllerNew script, the method that was responsible for the players&#8217; movement, I created a set of 4 if statements that would check which was the most recent direction the player had moved in, and would set the player to face in that direction using the <em><strong>SetFacingDirection() <\/strong><\/em>method. Therefore, the player would be facing a specific direction whether the player was currently moving in that direction, or had stopped moving entirely.<\/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>Furthermore, I created an <strong><em>Animate() <\/em><\/strong>method that would set an animator float called &#8220;<strong>isAttacking 1<\/strong>&#8221; to a certain value between 0 and 1 depending on what direction it was facing. Therefore if the player was facing right (90<sup>o<\/sup>) its <strong>isAttacking 1 <\/strong>float would be <strong>0.25f<\/strong> (90\/360).<\/p>\n\n\n\n<p>Then, using this &#8220;<strong>isAttacking 1<\/strong>&#8221; float and the &#8220;<strong>isAttacking<\/strong>&#8221; animator bool, the player would be able to play the correct animation for its attack, according to the direction its facing.<\/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 loading=\"lazy\" decoding=\"async\" width=\"508\" height=\"527\" src=\"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-21.png\" alt=\"\" class=\"wp-image-1192\" srcset=\"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-21.png 508w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-21-289x300.png 289w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-21-300x311.png 300w\" sizes=\"(max-width: 508px) 100vw, 508px\" \/><\/figure>\n<\/div>\n<\/div>\n\n\n\n<p>The one other difference made in the PlayerControllerNew script is preventing the player from moving during their attack, in order to do this I created a reference to the player&#8217;s AttackNew script, which was then set in the <em><strong>Start() <\/strong><\/em>method.<br>The <em><strong>Update() <\/strong><\/em>method would then perform a check to see if the player was attacking before allowing any inputs to move the player.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"676\" src=\"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-23-1024x676.png\" alt=\"\" class=\"wp-image-1194\" srcset=\"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-23-1024x676.png 1024w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-23-300x198.png 300w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-23-768x507.png 768w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-23-350x230.png 350w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-23-850x561.png 850w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-23.png 1161w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>This was the result of the new player:<\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-video\"><video controls src=\"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/MedalTVScreenRecording20250314173721-edit-tr-edit.mp4\"><\/video><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Bug Fixing<\/h2>\n\n\n\n<p>Immediately after committing this version of the player, I tested it against enemies and found that the player was still able to input movement while the death animation was playing.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"243\" src=\"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-24-1024x243.png\" alt=\"\" class=\"wp-image-1200\" srcset=\"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-24-1024x243.png 1024w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-24-300x71.png 300w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-24-768x182.png 768w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-24-850x202.png 850w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-24.png 1295w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>To fix this, I created an isDead bool in the PlayerHealth script which would be set to true when the player&#8217;s currentHealth less than or equal to zero.<br>In the PlayerControllerNew script, the <strong><em>Update()<\/em><\/strong> method would now check is the <em><strong>isDead bool <\/strong><\/em>was <em><strong>true<\/strong><\/em> before calling the <strong><em>Dash() coroutine<\/em><\/strong> or the <strong><em>ProcessInputs() method<\/em><\/strong>.<\/p>\n\n\n\n<figure data-wp-context=\"{&quot;imageId&quot;:&quot;6a06da8abc93c&quot;}\" data-wp-interactive=\"core\/image\" class=\"wp-block-image size-large wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"605\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-26-1024x605.png\" alt=\"\" class=\"wp-image-1203\" srcset=\"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-26-1024x605.png 1024w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-26-300x177.png 300w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-26-768x454.png 768w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-26-850x502.png 850w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-26.png 1422w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\taria-label=\"Enlarge\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on-async--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.imageButtonRight\"\n\t\t\tdata-wp-style--top=\"state.imageButtonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewBox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure>\n\n\n\n<p>However, after testing the player against multiple enemies to get a feel of the game&#8217;s combat, I noticed two more glaring bugs:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"202\" src=\"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-28-1024x202.png\" alt=\"\" class=\"wp-image-1209\" srcset=\"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-28-1024x202.png 1024w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-28-300x59.png 300w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-28-768x152.png 768w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-28-850x168.png 850w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-28.png 1234w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\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>This first bug was caused by the player&#8217;s script preventing any inputs after death, therefore after dying it would continue moving in the most recent input&#8217;s direction while the death animation was being played.<\/p>\n\n\n\n<p>However, this was a simple fix, as I had already written the logic for this, anticipating that this bug may occur, setting the player&#8217;s velocity to zero if the <strong><em>isDead bool<\/em><\/strong> was set to <strong><em>true <\/em><\/strong>in the <em><strong>Update() <\/strong><\/em>method. However, I had put the logic in an if statement that would only execute if the <em><strong>isDead bool <\/strong><\/em>was <em><strong>false<\/strong><\/em>. Therefore, all I had to do was change the order of the code in the <em><strong>Update() <\/strong><\/em>method.<\/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 loading=\"lazy\" decoding=\"async\" width=\"448\" height=\"524\" src=\"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-29.png\" alt=\"\" class=\"wp-image-1210\" srcset=\"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-29.png 448w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-29-256x300.png 256w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-29-300x351.png 300w\" sizes=\"(max-width: 448px) 100vw, 448px\" \/><\/figure>\n<\/div>\n<\/div>\n\n\n\n<p>However, this second bug, where the player could take multiple instances of damage at once, was an oversight I made when creating the PlayerHealth script, I had forgotten to implement I-frames, an important quality of life feature made in a lot of video games that feature combat.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"919\" height=\"258\" src=\"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-31.png\" alt=\"\" class=\"wp-image-1212\" srcset=\"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-31.png 919w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-31-300x84.png 300w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-31-768x216.png 768w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-31-850x239.png 850w\" sizes=\"(max-width: 919px) 100vw, 919px\" \/><\/figure>\n\n\n\n<p>To implement I-Frames, I created a <strong><em>iFrames float <\/em><\/strong>and a<strong><em> canTakeDamage bool<\/em><\/strong>, now, whenever the player would take damage, an <em><strong>IsDamaged() coroutine <\/strong><\/em>would be called which would set the <strong><em>canTakeDamage bool<\/em><\/strong> to false, wait for an amount of seconds equal to the <strong><em>iFrames float<\/em><\/strong> and then set the <strong><em>canTakeDamage bool<\/em><\/strong> to true again.<br>Whenever the player&#8217;s <em><strong>TakeDamage()<\/strong><\/em> method is called, it checks if the <strong><em>canTakeDamage bool<\/em><\/strong> is true before it executes.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"998\" height=\"579\" src=\"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-32.png\" alt=\"\" class=\"wp-image-1213\" srcset=\"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-32.png 998w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-32-300x174.png 300w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-32-768x446.png 768w, https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-32-850x493.png 850w\" sizes=\"(max-width: 998px) 100vw, 998px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>When developing the Player character further, we had noticed a lot of bugs and issues during this process, this post outlines our discussions, decisions and what I had to do in order to fix them. Outlining Issues and Changes Firstly, when Ayse, our Mechanics Designer pushed her initial version of the Player with its new&#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-1179","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 4 - 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\/05\/09\/player-pt-4\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Player - Pt 4 - E-Jay Tripoli (Year 2 Archive)\" \/>\n<meta property=\"og:description\" content=\"When developing the Player character further, we had noticed a lot of bugs and issues during this process, this post outlines our discussions, decisions and what I had to do in order to fix them. Outlining Issues and Changes Firstly, when Ayse, our Mechanics Designer pushed her initial version of the Player with its new...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/sites.wsagames.com\/et4g23\/2025\/05\/09\/player-pt-4\/\" \/>\n<meta property=\"og:site_name\" content=\"E-Jay Tripoli (Year 2 Archive)\" \/>\n<meta property=\"article:published_time\" content=\"2025-05-09T18:37:34+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-05-09T19:44:14+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-10.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=\"9 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\/05\/09\/player-pt-4\/\",\"url\":\"https:\/\/sites.wsagames.com\/et4g23\/2025\/05\/09\/player-pt-4\/\",\"name\":\"Player - Pt 4 - E-Jay Tripoli (Year 2 Archive)\",\"isPartOf\":{\"@id\":\"https:\/\/sites.wsagames.com\/et4g23\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/sites.wsagames.com\/et4g23\/2025\/05\/09\/player-pt-4\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/sites.wsagames.com\/et4g23\/2025\/05\/09\/player-pt-4\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-10.png\",\"datePublished\":\"2025-05-09T18:37:34+00:00\",\"dateModified\":\"2025-05-09T19:44:14+00:00\",\"author\":{\"@id\":\"https:\/\/sites.wsagames.com\/et4g23\/#\/schema\/person\/56387a1dc0de878bb33ce4c478f22963\"},\"breadcrumb\":{\"@id\":\"https:\/\/sites.wsagames.com\/et4g23\/2025\/05\/09\/player-pt-4\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/sites.wsagames.com\/et4g23\/2025\/05\/09\/player-pt-4\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/sites.wsagames.com\/et4g23\/2025\/05\/09\/player-pt-4\/#primaryimage\",\"url\":\"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-10.png\",\"contentUrl\":\"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-10.png\",\"width\":793,\"height\":139},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/sites.wsagames.com\/et4g23\/2025\/05\/09\/player-pt-4\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/sites.wsagames.com\/et4g23\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Player &#8211; Pt 4\"}]},{\"@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 4 - 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\/05\/09\/player-pt-4\/","og_locale":"en_US","og_type":"article","og_title":"Player - Pt 4 - E-Jay Tripoli (Year 2 Archive)","og_description":"When developing the Player character further, we had noticed a lot of bugs and issues during this process, this post outlines our discussions, decisions and what I had to do in order to fix them. Outlining Issues and Changes Firstly, when Ayse, our Mechanics Designer pushed her initial version of the Player with its new...","og_url":"https:\/\/sites.wsagames.com\/et4g23\/2025\/05\/09\/player-pt-4\/","og_site_name":"E-Jay Tripoli (Year 2 Archive)","article_published_time":"2025-05-09T18:37:34+00:00","article_modified_time":"2025-05-09T19:44:14+00:00","og_image":[{"url":"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-10.png","type":"","width":"","height":""}],"author":"et4g23","twitter_card":"summary_large_image","twitter_misc":{"Written by":"et4g23","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/sites.wsagames.com\/et4g23\/2025\/05\/09\/player-pt-4\/","url":"https:\/\/sites.wsagames.com\/et4g23\/2025\/05\/09\/player-pt-4\/","name":"Player - Pt 4 - E-Jay Tripoli (Year 2 Archive)","isPartOf":{"@id":"https:\/\/sites.wsagames.com\/et4g23\/#website"},"primaryImageOfPage":{"@id":"https:\/\/sites.wsagames.com\/et4g23\/2025\/05\/09\/player-pt-4\/#primaryimage"},"image":{"@id":"https:\/\/sites.wsagames.com\/et4g23\/2025\/05\/09\/player-pt-4\/#primaryimage"},"thumbnailUrl":"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-10.png","datePublished":"2025-05-09T18:37:34+00:00","dateModified":"2025-05-09T19:44:14+00:00","author":{"@id":"https:\/\/sites.wsagames.com\/et4g23\/#\/schema\/person\/56387a1dc0de878bb33ce4c478f22963"},"breadcrumb":{"@id":"https:\/\/sites.wsagames.com\/et4g23\/2025\/05\/09\/player-pt-4\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/sites.wsagames.com\/et4g23\/2025\/05\/09\/player-pt-4\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/sites.wsagames.com\/et4g23\/2025\/05\/09\/player-pt-4\/#primaryimage","url":"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-10.png","contentUrl":"https:\/\/sites.wsagames.com\/et4g23\/wp-content\/uploads\/sites\/27\/2025\/05\/image-10.png","width":793,"height":139},{"@type":"BreadcrumbList","@id":"https:\/\/sites.wsagames.com\/et4g23\/2025\/05\/09\/player-pt-4\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/sites.wsagames.com\/et4g23\/"},{"@type":"ListItem","position":2,"name":"Player &#8211; Pt 4"}]},{"@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\/1179","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=1179"}],"version-history":[{"count":4,"href":"https:\/\/sites.wsagames.com\/et4g23\/wp-json\/wp\/v2\/posts\/1179\/revisions"}],"predecessor-version":[{"id":1214,"href":"https:\/\/sites.wsagames.com\/et4g23\/wp-json\/wp\/v2\/posts\/1179\/revisions\/1214"}],"wp:attachment":[{"href":"https:\/\/sites.wsagames.com\/et4g23\/wp-json\/wp\/v2\/media?parent=1179"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sites.wsagames.com\/et4g23\/wp-json\/wp\/v2\/categories?post=1179"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sites.wsagames.com\/et4g23\/wp-json\/wp\/v2\/tags?post=1179"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}