It works perfectly fine when the condition is only pressing the X key. The problems arose when I added to hold the W key. it works only 30% of the time.
if (Input.GetKeyDown(KeyCode.X) && Input.GetKey(KeyCode.W)
{
Attackpressed = true;
}
if (Attackpressed)
{
Attackpressed = false;
if (!isAttacking)
{
isAttacking = true;
}
if (IsGrounded())
{
PlayAnimation(Attackup);
}
Invoke("AnimationStop",0.3f);
{
PlayAnimation(Attackupaway);
}
Invoke("AnimationStop",0.3f);
}
while holding the w key and pressing the x key, and when it is not grounded, it activates the “attackupaway” animation. I don’t want to add a transition to the animation because I have a really hard time when the logic gets complicated. Thank you
New contributor
Sam Jacob is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.