Problem when using the same key for different actions
Morning!
I've been having the following issue lately.
I'm making a game where the character can dash omnidirectionally using the keyboard arrows.
The thing is, if i try to dash Up, Down, Left or Right there's no problem at all, the problem start when i add the other four directions.
Due to the way that unity read inputs, even though i specify that it can only dash up if the right arrow isn't being pressed, sometimes it has trouble reading this and will dash up instead of diagonally.
Anybody knows if there's a way that I can fix this? Thanks in advance!
Here's the dash code just in case
if (Input.GetButton("Dash") && !backpackJump)
{
if (Input.GetButton("Right") && Input.GetButton("Up"))
{
dashDirection = DashDirection.diagonalUpRight;
backpackJump = true;
isGrounded = false;
dashCase = 1;
dashedDiagonalUpRight = true;
dashedDiagonalUpLeft = false;
dashedDiagonalDownLeft = false;
dashedDiagonalDownRight = false;
count += 1;
noDirection = 1;
Debug.Log(count);
}
else
if (!Input.GetButton("Right") && Input.GetButton("Up"))
{
dashCase = 7;
dashDirection = DashDirection.Up;
backpackJump = true;
isGrounded = false;
}
}
Comment