Player floats slightly above ground when I press start

I’m pretty new to Unity so I’ve been following tutorials. I followed this tutorial exactly: 2D Player Movement and Jumping in Unity - YouTube
But my player floats slightly above the ground every time I press “Play”, as you can see in the photo.

I have no idea why this is happening, and the player is unable to jump because it is not touching the ground (it could jump before I finished the second half of the tutorial where you make a ground check)

Thanks :slight_smile:

Are you using rigid bodies? what kind of ground check did you do? there are a few questions for you. If you can provide us some code, we may be able to help you.

@BrokeLol
I am using rigid bodies, and the tutorial I followed mainly uses Box Colliders (2D) for the ground check. I have a box collider on the ground, and the player. The player also has a child object which is used to have a box collider that is just under the player’s feet.
I will copy-paste my code form my “Movement2D” and “Grounded” scripts:
Movement2D:

public class Movement2D : MonoBehaviour
{
public float moveSpeed = 1f;
private float jumpY = 3f;
public bool isGrounded = true;
// Start is called before the first frame update
void Start()
{

}

// Update is called once per frame
void Update()
{
    Jump();
    Vector3 movement = new Vector3(Input.GetAxis("Horizontal"), 0f, 0f);
    transform.position += movement * Time.deltaTime * moveSpeed;
    
}
void Jump()
{
    if (Input.GetButtonDown("Jump") && isGrounded == true)
    {
        gameObject.GetComponent<Rigidbody2D>().AddForce(new Vector2(0f, jumpY), ForceMode2D.Impulse);
    }
}

Grounded:

public class Grounded : MonoBehaviour
{
GameObject player;
// Start is called before the first frame update
void Start()
{
player = gameObject.transform.parent.gameObject;
}

// Update is called once per frame
void Update()
{
    
}
private void OnCollisionEnter2D(Collision2D collision)
{
    if (collision.collider.tag == "Ground")
    {
        player.GetComponent<Movement2D>().isGrounded = true;
    }
}
private void OnCollisionExit2D(Collision2D collision)
{
    if (collision.collider.tag == "Ground")
    {
        player.GetComponent<Movement2D>().isGrounded = false;
    }
}

tysm for your help! :slight_smile: