# Animation Change Delay When Landing On Ground

I am working on a 2d platformer-like game in Unity. My problem is that when my player character jumps and lands back on the ground, there is a slight delay at times when transitioning to the player idle animation. This is not due to exit time. Instead, upon researching this topic, I found that my real problem lies in the Unity physics loop(FixedUpdate).

FixedUpdate, as the name implies, is called a fixed amount of times, not every frame. My animator relies on a Jumping boolean to tell it whether or not to be in the jumping animation. In my code, the Jumping boolean is set to false when the player lands on the ground. This is handled by OnCollisionEnter2D, which runs on FixedUpdate.

This is were I think my problem lies:

private void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.CompareTag("Ground"))
{
_isOnGround = true;
_animator.SetBool("Jumping", false);
}
}


I need to know whether or not the player is colliding with the ground, So I setup a tag. I need to find a way to constantly check whether or not I am colliding with the ground, So that I do not see an animation transition delay.

Any Ideas of how I could accomplish this?

You should check out Physics2D.OverlapArea. It takes a rectangle and checks if it is overlapping with another sprite. Here is some code I have been using that works well.

//Corners of the rectangle to check
public var top_left : Transform;
public var bottom_right : Transform;