Player P2 [Altering the Dash]

Following up from implementation, I had to tweak my original code to prevent the player from changing their direction when the dash is active, to make the dash mechanic skillfully rewarding to better players. I tried to implement it but got frustrated as after I tweaked the code, it broke it and made the dash go on infinitely, look below to see how I fixed it and made it work perfectly!


Team Discussion

After receiving feedback from our Lead Programmer, E-Jay, I had to revisit my code and do some tweaking. My code was complimented, but to fit in with the roguelite vibe, the player shouldn’t be able to turn/change direction mid-dash. So I had to get cracking on a fix in response.

I tried to research how to do this without a lead from him. As this is my second experience coding, I found it terribly difficult. I couldn’t find anything specific to it, but E-Jay gave me a suggestion after I expressed my struggle. He suggested to:

  • Create a bool to store if the player is dashing or can dash.
  • Add those bools into the current code when active/inactive.
  • In the update method, check if the player is dashing and make it return to nothing.

After getting some direction from this response, I could now find material to aid me in creating this.


Research

This video completely encapsulates what E-Jay told me I needed to achieve the locking aspect of the dash. I will use this video to aid me in the order that I need to implement those features, as Unity plays code from the top to the bottom in its methods.


Production

First Try

Here is the original updated code, I’ve added in two new bools (isdashing and candash) and have given them their own section. These will store the current state of these two effects and will get updated when the dash becomes active or inactive. After I did this, the dash became infinite and would not stop, I became super frustrated with it and gave up, asking E-Jay for help. Understandably he was busy with working out the games procedural generation, so I decided to give it another go.

Second Try

After doing a test run, I found that it wouldn’t work. This was due to the order of the code. I had to alter the order by placing the if is dashing statement under the input key code section. This made it so the game would check to see if the player pressed the input and made it active, rather than going straight to checking if the dash was active, not giving the player a chance to press an input. This fixed the ‘infinite dash glitch’ I encountered.


Personal Review

I learnt a bunch from encountering my first bug in this project. It taught me to be patient with myself and to give myself a chance to work things out, rather than taking the easy way out from getting someone else to do it. I learnt what it means to be a coder by solving the problem myself and to always put notes in my code so I understand what is happening with each line of code.