I am slowly falling down with the jump animation

Hello everyone, have have some small issue, but i still can’t understand, what;s wrong. I have jump system: Character (with capsule collider and rigid body, and they set up properly), Empty gameobject with ray, for detecting is Player grounded
Before i added jump animations - everything worked correctly. I have 3 jump animations

  1. Anticipation
  2. Floating
  3. Landing

When Floating is playing - my character falling really slow, without animation I have normal fall speed
Here is my code

public class Jump : DragControllerForwad
{
    public float jumpHeight = 10f;
    public bool isGrounded;

    //Character rigid body
    public Rigidbody rb;

    //Character animator
    [SerializeField]
    Animator anim;

    void Start()
    {
        rb = transform.Find("animation").GetComponent<Rigidbody>();
        anim = transform.Find("animation").GetComponent<Animator>();
    }

    void Update()
    {
        RayCasting();
    }

    // Ray for detecting ground
    protected override void RayCasting()
    {
        Ray ray = new Ray(transform.position, transform.forward);
        RaycastHit hitInfo;

        if (Physics.Raycast(ray, out hitInfo, .5f))
        {
            Debug.DrawLine(ray.origin, ray.origin + ray.direction * .5f, Color.green);
            if (hitInfo.collider.tag == "Ground")
            {
                isGrounded = true;
            }
            else
            {
                isGrounded = false;
            }
        }
        else
        {
            isGrounded = false;
            Debug.DrawLine(ray.origin, ray.origin + ray.direction * .5f, Color.red);
        }

        // Code for jump animations
        if (isGrounded == true)
        {
            anim.SetBool("isJump", false);
            if (Input.GetKeyDown(KeyCode.Space))
            {
                rb.AddForce(Vector3.up * jumpHeight, ForceMode.Impulse);
            }
        }
        else if(isGrounded == false)
        {
            anim.SetBool("isJump", true);
        }
    }

}

My animator controller:

There doesn’t seem to be any clear indication in your code as to when your player is in the “floating” state. There isn’t any specific “Float” animation, nor is there a boolean or enum value to check whether it is. And I assume that in the “floating” state you don’t want any vertical velocity at all; and also that this “floating” only happens at the peak of your jump, correct?
And what is the length of the floating determined by? Is it the length of the animation? The length of the jump button being held down?
Once you can define what exactly this “floating” state is and how it functions then I can provide some help as to how to keep the character still in the air during this time.

Try editing the gravity scale in the Rigidbody of your player. Or go to the project settings and adjust the default gravity,

Edit: Previous answer: Try moving your Animator away from the Player gameobject, make it a gameobject child. Also make sure that your code finds the animator after you made the change.


New answer: Sorry about the last one. You shouldn’t be moving your animator away, you should be creating a new gameobject called player and move all your behaviour and collider in there and leave just the animator in what’s your current Player. If you remove the animator from the current player, it will not work because the animator will be looking for the previous hierarchy and will not find it.


So basically:

  1. Rename your current Player to Animator.
  2. Create a new empty object in the same position as the Animator.
  3. Paste all your behaviour and colliders to the new object.
  4. Remove all the behaviour from your Animator.
  5. Make your Animator a child of your new Player.
  6. Test.

I finally found out how to fix it, if you guys will have the same problem - try tu turn off allow root animation in your animator in inspector