# 2D objects gets stuck on the ground/wall?

Hi!

I just noticed in my small 2D game that the objects stop on the ground. Like I have a conveyor belt and when the cubes move on it they randomly get stuck. This also happens when they slide down next to a wall. How can I fix this?

Try using Edge colliders on your box instead. It worked great for me. Here’s where I found that out http://forum.unity3d.com/threads/rigidbody-getting-stuck-on-tiled-wall.220861/

Hope this helps!

Physics Material 2D worked for me.

• Create a Physics Meterial 2D.

• Set friction is zero

• Assign it into colliders (don’t need for player)

Sounds similar to some prototype games where if the player jumps and force is being added to a rigid body to make the player move, and he hits a wall as long as the player is holding the arrow key down there is still being force applied and he will stick to the wall until you let go of the move key. That has to do with the force being applied to the rigid body sideways is more than the force that physics gravity can overcome. Sounds to me like every once in a while the Gravity from the Physics is too much force downwards than is being applied to the rigid body sideways causing the object to “Stop” it’s not really stopping, more than it’s just going downwards faster than sideways so to speak so it looks like it’s not moving. Either try adding more force to the object or lower the Physics Gravity from Project Settings.

I think it’s to do with the fact that the physics engine is not 100% accurate, and that may well boil down to the fact that floating point numbers are not 100% accurate. While unity/physics is probably trying to keep the object flush to the surface, sometimes there is a tiny little bit of penetration into the surface, especially if forces are being applied or surface are moving. I believe what happens is the moving object’s collider sinks into the surface just ever so slightly, enough that when it gets to the corner of a box collider (or other types also) it sort of collides against the side of that collider, and sometimes this makes the object bounce up as if it hit something, or also can make the object get stuck. It’s the joins between colliders combined with slightly imprecice physics that is the problem, in my opinion. One fix I found is making your object kinematic and moving it without forces. Otherwise I guess you could program some kind of `fix` in a script, like OnCollisionStay2D, making sure the object is moved up a little bit if it enters the surface?

Another solution is to give the object a PhysicsMaterial2D and set the friction on it to zero. This worked for me. But depending on how you’re moving this object, it might have some unintended consequences.

adding a tiny circle collider to make contact with the ground makes it stop snagging, however this causes it to get random noticeable bumps on my game

I know this is really late, but I was having a similar problem.

If the gameObject has a rigidbody2D, try changing it from Start Awake to Never Sleep and see if it fixes the issue.

I added a PhysicsMaterial2D to the boxcolliders of the grouund/platforms and set it to 0 friction and 0 bounciness. The only problem it creates is if you have objects on the platform they will kind of slide around, don’t know how to fix this.

Well, I’ve just set Bounciness to 0.1 in PlayerPhysics material on Player box collider.

1. Create a custom material for Player collider
2. Set Bounciness to 0.1
3. Apply

Now player will bounce a little from the ground, but it’ll be so little that in reality we don’t even see this.
That’s a simple solution I came to while walking in a park. Enjoy

Wow… I tried every single advice here and nothing works. Could I maybe improve my script? I set the “errorCorrection” to the biggest value I could get without it getting noticeable in game (also tried it with only affecting the y-value).

``````private void OnTriggerStay2D(Collider2D collision)
{
if (collision.tag == "ground")
{
myTransform.position = new Vector2(myTransform.position.x + errorCorrection, myTransform.position.y + errorCorrection);
}
}
``````

Otherwise I think I’ll just go with single box collider stretched out over several tiles which feels like a lot of unnecessary work but it’s the only solution that work in my project…

I had a similar issue when using a BoxCollider2D in combination with TilemapCollider2D. All other solutions mentioned elsewhere (e.g. capsule colliders or edge colliders) did not help in my case or showed other undesirable behaviour (e.g. “climbing” or “shooting” over edges).

Here are the steps:

• Assign a physics material with 0 friction and 0 bounciness to both colliders
• Set the property “edge radius” of the box collider to a small value (0.05)
• In Projects Properties → Physics: Reduce the default contact offset

These settings also work when directly setting the velocity of the rigidbody (which is what I’m doing with my current player controller script) as I need snappy behaving controls.

Hope that helps!

Hi @RealMTG I know I’m late to the game, but just in case this helps anyone else… I ran into the exact same problem. After much experimention and working really hard to pinpoint what was causing this, I found that changing from a box collider to a capsule collider completely solved the problem. It seems the capsule collider is more forgiving. My GameObject completely stopped sticking!