Search code examples
c#unity-game-enginegame-enginegame-physics

unity character not moving while jump


hi every one thank you all for reading my question , i am creating forever runner game using unity 5, i want my character to jump above the obstacle but i want the object move forward during the jump, but the jump that i have take a very small time and the character stay very close to the ground,and not moving forward -while jumping- even i am applying a force to it as in the code, so what can i do ?

void Start () 
{
    anim = GetComponent<Animator>();
    rbody = GetComponent<Rigidbody>();
    verticalJumpPower = 80f;
    horizantalJumpPower = 1000f;
    playerVelocity = 10f;
    isGrounded = true;
}

***in update function :*** 

if(Input.GetKeyDown (KeyCode.UpArrow))
{
    rbody.AddForce(new Vector3(0,verticalJumpPower,horizantalJumpPower));
    anim.SetBool("jump",true);
    isGrounded = false;


    } 

Solution

  • i added anim.applyRootMotion = false; and it worked