I am using a Trigger to detect when the player lands on the ground after jumping but the issue is after jumping for a while the trigger will randomly stop detecting the ground and make it to where the player can not jump anymore
using UnityEngine;
public class charController : MonoBehaviour
{
Transform Horizontal;
public Rigidbody2D Player;
public float speed = .2f;
public float jumpHight = .3f;
bool isGround = true;
void FixedUpdate ()
{
float HorAxis = Input.GetAxis("Horizontal");
Vector2 Movment = new Vector2(HorAxis , 0);
transform.Translate(Movment * speed);
if (Input.GetKeyDown(KeyCode.Space) && isGround == true)
{
Player.AddForce(Vector2.up * jumpHight);
isGround = false;
}
}
private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.gameObject.tag == "Floor")
{
isGround = true;
}
}
}