[Problem]Collider Issues when Sprites Meet
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:
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.
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);
}
}
Show me the gameobject in your scene window with it's collider shown; it sounds like a collider issue not a code issue.
Answer by wittledemon · Aug 27, 2019 at 04:56 PM
Players Collider is first and the object collider is second.


Show the player object in the scene window please, not the inspector; I'm trying to see if you need to resize your collider on the player
Answer by I_Am_Err00r · Aug 27, 2019 at 06:42 PM
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.
It actually was the code that was the problem I reworked the code out piece by piece and found my mistake its smoothed out now and lot lighter on the code. Thanks for the assistance.
Your answer