When the player is grounded plays the falling and landing animation in an eternal loop

Capsule Collider height: 2; Capsule Collider radius: 0.5
While the player is rgounded the Grounded the Falling and Grounded parameters turn on and off continuously. This is the Animator window

Conditions:
From Movements to Jump, Jump parameter has to be triggered.
From Jump to Falling, Falling parameter has to be true.
From Falling to Landing, Grounded parameter has to be true.
From Movements to Falling, Falling parameter has to be true.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Game.Manager;

public class PlayerController : MonoBehaviour
{
    InputManager inputManager;
    Animator animator;
    Rigidbody playerRb;

    CapsuleCollider collider;

    bool hasAnimator;

    bool grounded;

    [SerializeField] float jumpFactor = 250f;

    float Dis2Ground;
    [SerializeField] LayerMask GroundCheck;

    [SerializeField] float airResistance = 0.8f;

    void Start()
    {
        collider = GetComponent<CapsuleCollider>();
        Dis2Ground = collider.bounds.extents.y;

        inputManager = GetComponent<InputManager>();
        playerRb = GetComponent<Rigidbody>();
        hasAnimator = TryGetComponent<Animator>(out animator);

        fallingHash = Animator.StringToHash("Falling");
        jumpHash = Animator.StringToHash("Jump");
        groundHash = Animator.StringToHash("Grounded");
    }
    private void FixedUpdate()
    {
        HandleJump();
        SampleGround();
    }

    private void HandleJump()
    {
        if (!hasAnimator) return;
        if (!inputManager.Jump) return;

        animator.SetTrigger(jumpHash);
    }

    public void JumpAddForce()
    {
        playerRb.AddForce(Vector3.up * jumpFactor, ForceMode.Impulse);
        playerRb.AddForce(-playerRb.velocity.y * Vector3.up, ForceMode.VelocityChange);
        animator.ResetTrigger(jumpHash);
    }

    private void SampleGround()
    {
        if (!hasAnimator) return;

        RaycastHit hitInfo;
        if(Physics.Raycast(transform.position, Vector3.down, out hitInfo, Dis2Ground + 0.1f))
        {
            grounded = true;

            SetAnimationGrounding();
            return;
        }
        Debug.Log(grounded);
        animator.SetFloat(zVelHash, playerRb.velocity.y);
        grounded = false;
        SetAnimationGrounding();
        return;
    }

    private void SetAnimationGrounding()
    {
        animator.SetBool(fallingHash, !grounded);
        animator.SetBool(groundHash, grounded);
    }
}

I finally found the answer @gabrielebotrugno970 so I edited this answer so it doesn’t get lost in the comments.
There’s a lot of things going on but the first thing I wan’t to say is, having a collider already set into your character and all environmet objects, you should think about managing the collisions throught their native methods.

(1) The PlayerController code. It’s all the same but I changed the following methods:

 private void HandleJump()
    {
        if (!hasAnimator) return;
        if (inputManager.Jump && grounded)
        {
            animator.SetTrigger(jumpHash);
        }
    }

    public void JumpAddForce()
    {
        playerRb.AddForce(Vector3.up * jumpFactor, ForceMode.Impulse);
        playerRb.AddForce(-playerRb.velocity.y * Vector3.up, ForceMode.VelocityChange);
        animator.ResetTrigger(jumpHash);
    }

    private void SampleGround()
    {
        if (!hasAnimator) return;

        RaycastHit hitInfo;
        bool isStillGrounded = Physics.Raycast(transform.position, Vector3.down, out hitInfo, 0.1f);
        if (grounded != isStillGrounded)
        {
            grounded = isStillGrounded;
            Debug.DrawRay(transform.position, hitInfo.point, Color.red, 2, false);
            animator.SetFloat(zVelHash, playerRb.velocity.y);
            SetAnimationGrounding();
        }
    }

We were raycasting way under the player’s feet.
The jump could happen even when falling, so qe avoided that by checkng if player was grounded.

(2) There’s something wrong with your “floor” mesh. I changed it for a 3D box and it started refistering collisions properly. Maybe try and change just the mesh collider for a box collider.


(3) The animator controller needed some tweaks. Jump to Falling has to have Has time exit set to 1 and NO condition. That’s why just when the jump starts we set the Falling trigger so it can transition to Falling animation. Also transition duration should be 0%.
Falling to Landing should have NO Exit time. Just the condition (grounded).


Even with these changes, it’s still no perfect. The way the jump is being managed (I have no clue where’s JumpAddForce() method being called from) it can cause some unexpected behaviours.
Other thing might be for example avoiding player movement while landing animation is still playing.

Anyways, I hope this helps :slight_smile: