- Home /
Only one animation playing NON-STOP!!?
Hi, I am making a 2D game and I am having trouble with my player. For some reason when I run the game, It just keeps playing a jump animation for my character:
That is a picture of the end of the jump animation.
The animator is fine. The animations have the correct frames. Everything seems right, except for when you actually play the game. Will someone please help me?
If you give me your email, I can dropbox it to you because the size of the gif is to big, even when compressed.
Watching a character jumping up and down isn't going to tell us anything we don't know already.
If you have the window for your animator open and deselect maximize on play you can see what settings are being triggered. Assu$$anonymous$$g you're using $$anonymous$$ecanim when you say Animator.
The correct settings are being triggered. The frames are also correct. This is a 2D game, by the way, and I think $$anonymous$$ecanim is for 3D?
EDIT: Oh, wait. Now the animator is not working.
EDIT 2: When I run the game, sometimes the animator works, and sometimes it doesn't, but either way, the jump animation plays the whole time.
There's not enough information to give a solution.
Check all the transitions between your animation states, and cross-reference the animation controller's variables with your scripts, especially any character controllers you might use.
@wojtask12 If you mean the functions from the script, then it is the FixedUpdate function -
private void FixedUpdate()
{
m_Grounded = false;
// The player is grounded if a circlecast to the groundcheck position hits anything designated as ground
// This can be done using layers ins$$anonymous$$d but Sample Assets will not overwrite your project settings.
Collider2D[] colliders = Physics2D.OverlapCircleAll(m_GroundCheck.position, k_GroundedRadius, m_WhatIsGround);
for (int i = 0; i < colliders.Length; i++)
{
if (colliders[i].gameObject != gameObject)
m_Grounded = true;
}
m_Anim.SetBool("Ground", m_Grounded);
}
then the move function-
public void $$anonymous$$ove(float move, bool jump)
{
//only control the player if grounded or airControl is turned on
if (m_Grounded || m_AirControl)
{
// The Speed animator parameter is set to the absolute value of the horizontal input.
m_Anim.SetFloat("Speed", $$anonymous$$athf.Abs(move));
// $$anonymous$$ove the character
m_Rigidbody2D.velocity = new Vector2(move*m_$$anonymous$$axSpeed, m_Rigidbody2D.velocity.y);
// If the input is moving the player right and the player is facing left...
if (move > 0 && !m_FacingRight)
{
// ... flip the player.
Flip();
}
// Otherwise if the input is moving the player left and the player is facing right...
else if (move < 0 && m_FacingRight)
{
// ... flip the player.
Flip();
}
}
// If the player should jump...
if (m_Grounded && jump && m_Anim.GetBool("Ground"))
{
// Add a vertical force to the player.
m_Grounded = false;
m_Anim.SetBool("Ground", false);
m_Rigidbody2D.AddForce(new Vector2(0f, m_JumpForce));
}
}
@wojtask12 @Cherno Turns out the jumping is a collider problem.
It looks like he is floating on a platform.
Any Ideas?
BTW, he is not jumping.
Answer by purnjay · Jun 15, 2016 at 06:23 AM
the problem is that you are keeping transition from any state to jumping so when the game will start it will first go to idle animation and then jump and then it will replay again and again .....
It would be good If you will also give a list of the parameters and where you have used them ..
but I think this is the problem..
Answer by kittc522 · May 17 at 02:18 PM
Make sure on the animation you disable looping. Also, like purnjay said, it's possible you are transitioning between two animations over and over. In the Animator make sure if it's going from idle or any state to the jump that the there you don't have an arrow pointing from both objects to each other. It should look something like this but with jump in place of the run animation. Make sure there isn't an arrow pointing back at idle because that will create a loop of jumping back and forth between the two.
Hopefully this helps? I'm not exactly sure what the problem is but that would be my guess :)
Your answer
![](https://koobas.hobune.stream/wayback/20220612082745im_/https://answers.unity.com/themes/thub/images/avi.jpg)