using UnityEngine; public class FallingDetection : MonoBehaviour { public GameObject _LevelManager1; private CharController script1; bool grounded; private Rigidbody2D playerRigidbody; public bool isFalling; private Animator animator; public int counter = 0; private void Start() { animator = GetComponent(); playerRigidbody = GetComponent(); } private void Update() { script1 = _LevelManager1.GetComponent(); grounded= script1.grounded; Vector3 velocity = playerRigidbody.velocity; if (!grounded && velocity.y < -0.1f){ if(counter++>90||isFalling){ isFalling = true; animator.SetBool("IsFalling", true); counter = 0;} } else { isFalling = false; counter = 0; animator.SetBool("IsFalling", false);} } }