Player bounce when not supposed to

void Movement(Vector2 move, bool yMovement)
{
float distance = move.magnitude;

        if (distance > minMoveDistance)
        {
            int count = rb2d.Cast(move, ContactFilter, hitBuffer, distance + shellRadius);

            hitBufferList.Clear();

            for(int i = 0; i < count; i++)
            {
                hitBufferList.Add (hitBuffer*);*

}

for (int i = 0; i < hitBufferList.Count; i++)
{
Vector2 currentNormal = hitBufferList*.normal;*

if (currentNormal.y > minGroundNormalY)
{
grounded = true;

if (yMovement)
{
currentNormal = groundNormal;
currentNormal.x = 0;
}
}

float projection = Vector2.Dot(velocity, currentNormal);
if (projection < 0)
{
velocity = velocity - projection * currentNormal;
}

float modifiedDistance = hitBufferList*.distance - shellRadius;*

distance = modifiedDistance < distance ? modifiedDistance : distance;
}
}

rb2d.position = rb2d.position + move.normalized * distance;
}
So my issue is that sometimes when my player hits a platform it will bounce of the ground making it immposible to jump again. How can I make shure that the player stays grounded until the jump button is pressed again, instad of bouncing for no reason?

Good day.

Most probably it bounce due to phicis material, or rigidbody collisions.

Best solution i think is when detect the ground, to force the rigidbody.velocity.y to 0 (the vertical component of the velocity)

rb = rigidbody

rb.velocity = new Vector3(rb.velocity.x, 0, rb.velocity.z);

This way it will continue advancing the same speed but vertical speed will be set to 0 during 1 frame, preventing the bounce.

Bye!