- Home /
Punch animation problem
Hi,
I'm, having trouble with the punch animation on my game, i have 2 switches that controls the animations and it's conditions, but i don't know how to express a condition to make que character wait until the punch animation ends.
right now i have this situation:
switch (m_state) {
case States.idle:
if ((Input.GetKeyDown (KeyCode.UpArrow)) && (grounded)) {
m_state = States.jump;
} else if (Input.GetKeyDown (KeyCode.Space))
m_state = States.punch;
else if ((m_rb.velocity.y == 0) && (m_rb.velocity.x != 0)) {
m_state = States.run;
}
break;
case States.run:
if ((Input.GetKeyDown (KeyCode.UpArrow)) && (grounded)) {
m_state = States.jump;
} else if (Input.GetKeyDown (KeyCode.Space)) {
m_state = States.punch;
} else if (this.m_animator.GetCurrentAnimatorStateInfo (0).IsName ("run"))
m_state = States.run;
print ("1");
break;
case States.jump:
if ((m_rb.velocity.y == 0) && (m_rb.velocity.x != 0)) {
m_state = States.run;
} else if (Input.GetKeyDown (KeyCode.Space)) {
m_state = States.punch;
}
break;
case States.punch:
if ((Input.GetKeyDown (KeyCode.UpArrow)) && (grounded)) {
m_state = States.jump;
} else if (Input.GetKeyDown (KeyCode.Space))
m_state = States.punch;
else if ((m_rb.velocity.y == 0) && (m_rb.velocity.x != 0)) {
m_state = States.run;
}
break;
}
//switch of which state
switch (m_state) {
case States.idle:
m_animator.SetInteger ("state", 0);
break;
case States.run:
m_animator.SetInteger ("state", 1);
m_rb.velocity = new Vector2 (m_rb.velocity.x, m_rb.velocity.y);
break;
case States.jump:
m_animator.SetInteger ("state", 1);
if((Input.GetKeyDown(KeyCode.UpArrow))&&(grounded))
m_rb.velocity = new Vector2 (m_rb.velocity.x, jumpForce);
break;
case States.punch:
m_animator.SetInteger ("state", 2);
break;
}
the animation goes from running to punch, and return instantly. I want to make it wait finish the punch animation. Any ideas?
Comment
Your answer
Follow this Question
Related Questions
Can the animation editor create local rotational data? 3 Answers
PLaying an animation on click 2 Answers
Apply root motion animation problem 0 Answers
Adding animation clips via script 2 Answers
How to move character with specific units with animation? 2 Answers