Bonus Challenges: Day 1



Allow the player to run by holding a key



︎︎︎ Tips:
  • Create separate variables representing the player’s walk speed, run speed, and current speed.
  • Set the current speed according to player input using the Input.GetKey function.
  • Consider limiting how long you can run for with a stamina variable that depletes when you run, and refills when you don’t. Check out the bonus challenges on Day 2 to see how to make a meter to represent the stamina.
︎︎︎ Links:
Input.GetKey


Give the player dash (a short burst of speed) when they press a key

As opposed to continuous run, this ability is only triggered the moment the player presses a key.

︎︎︎ Tips:
  • Create separate variables representing the player’s walk speed, dash speed, and current speed.
  • Use Input.GetKeyDown to set that variable to a high value the moment the user presses the key.
  • In the Update() function, slow the player down to their default movement speed. You can use subtraction or the Mathf.MoveTowards function for this.
  • Consider adding a cooldown to the dash with a timer.