I fairly certain this has been asked before but not sure what to google to get correct information.

I have a collider that when I jump and it collides with another collider that sometimes not always it bleeds into the sprite it collides with. Could someone direct me as to how to fix this issue please?

I currently tried a few methods but none worked or they created other issues I was not satisfied by for instance:

  1. Placing my jump method into the Fixed update Method as I did with my movement to stop the jitters of the collision. However, this had no effect.
  2. Making the collider it was connecting with larger in the y position. However, this one had the effect of walking on nothing by the time I got it big enough to stop the bleeding effect.

In case code is needed:

    private void Jump(bool jump)
    {
        //if rb velocity = 0 and jump = true
        if (rb.velocity.y == 0 && jump)
        {
            //rb velocity = upward at a specivied jumpSpeed
            rb.velocity = Vector2.up * jumpHieght;
        }
        JumpStates();
    }
    private void JumpStates()
    {
        //if velocity < 0
        if (rb.velocity.y < 0)
        {
            //velocity += up * gravity * highJumpFallSpeed * delta
            rb.velocity += Vector2.up * Physics2D.gravity.y * (highJumpFallSpeed - 1) * Time.deltaTime;
            //spriteAnimation change isJumping true
            animationState.SetBool("isJumping", true);
        }
        //if velocity > 0 and jump false
        else if (rb.velocity.y > 0 && !Input.GetButton("Jump"))
        {
            //velocity += up * gravity * highJumpFallSpeed * delta
            rb.velocity += Vector2.up * Physics2D.gravity.y * (lowJumpFallSpeed - 1) * Time.deltaTime;
            //spriteAnimation change isJumping true
            animationState.SetBool("isJumping", true);
        }
        else if (rb.velocity.y > 0)
        {
            //spriteAnimation change isJumping true
            animationState.SetBool("isJumping", true);
        }
        else
        {
            //spriteAnimation change isJumping false
            animationState.SetBool("isJumping", false);
        }
    }

Players Collider is first and the object collider is second.

Your collider does look a little short on the top, I would ensure that everything is outside of the collider, but it looks setup correctly honestly.


Let me help you out by giving you a script that will check for ground, if grounded allow you to jump; if you want that just reply to this comment and I will share and explain it with you; I honeslty don’t understand a lot of the if statements in you script and would prefer to just write something up for you because it will work and require much less back and forth.