Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Running while jumping issue.

Discussion in 'Animation' started by Plopikoosy, Apr 13, 2015.

  1. Plopikoosy

    Plopikoosy

    Joined:
    Dec 20, 2014
    Posts:
    11
    Hey guys,

    So I am currently using the standard assets 2D character controller. I have added a simple double jump part to the code. Now, when I try to do the animation for the character, the jump does not activate until the second jump has been completed. So basically you can run while jumping for the first jump. It doesn't seem to pick up my Ground variable changing to false until after the second jump.

    If anyone knows how to fix this please let me know :) Thanks


    Some of the jump code:

    if ((m_Grounded || !doubleJump) && jump && m_Anim.GetBool ("Ground"))
    {
    // Add a vertical force to the player.

    m_Grounded = false;

    m_Anim.SetBool ("Ground", false);

    GetComponent<Rigidbody2D>().velocity = new Vector2(GetComponent<Rigidbody2D>().velocity.x, 0);

    m_Rigidbody2D.AddForce(new Vector2(0f, m_JumpForce));

    }
     
    Last edited: Apr 13, 2015
  2. CDF

    CDF

    Joined:
    Sep 14, 2013
    Posts:
    1,282
    Have you disabled "Has Exit Time" on your transitions?
     
    Plopikoosy likes this.
  3. Plopikoosy

    Plopikoosy

    Joined:
    Dec 20, 2014
    Posts:
    11
    Thank you, this was my issue :)