I'm trying to code a dash/air dash for a 2D platformer. In my character controller's FixedUpdate()
, I have various if
statements that cause certain actions when a button is pressed.
To disable player input while the dash was happening, I tried putting Dash()
in an IEnumerator
with a simple test code like this:
IEnumerator Dash() {
if (player.GetAxis("Horizontal") < 0)
{
thePlayer.GetComponent<HeroController>().enabled = false;
yield return new WaitForSeconds(0.5f);
move = move * 2;
thePlayer.GetComponent<HeroController>().enabled = true;
}
}
But since the character's physics are inside the character controller, both the player's input and the character's movements are stopped when the controller is disabled. How can I disable inputs while still allowing the character to dash?