What is causing my Collision2D to stick to each others?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By GrandNecro

I’m running into a bug where two CollisionShape2D are sticking to each others.
However, this only occurs when one collisionshape1 touches the buttom side of collisionshape2 – this does not happen on the side or when the shape1 touches the top side of shape2. I can’t understand why it only happens from the bottom side but not any other side.

Example GIF

The positions of the player node is sync using the new MultiplayerSynchronizer. The code for movement is minimalist. The scene tree is also nothing special

Scene Tree

func s_move(move_vector):
  if move_vector == Vector2(0,0):
    velocity = Vector2(0,0)
    velocity += move_vector * MOVE_SPEED
:bust_in_silhouette: Reply From: GrandNecro

I figured it out so I’m gonna answer my own question.
Instead of using move_and_slide(), I replaced it with move_and_collide(velocity * delta).

move_and_slide seems to have some internal vector calculation that doesn’t work very well with top-bottom 2d game. It seems like it’s more suited for 2d platform game.


God bless, got the same problem. I think it’s an actual bug because my two circle colliders got stuck only when ‘enemy’ collider approached from up top, left/right/bottom approach collided fine.

1 Like

Hi all, I realise this is an old post but I found that this was due to “Moving Platform” floor layers being enabled in the “CharacterBody2D” node of a scene.

If you click on the CharacterBody2D node, you can see in the inspector there’s a dropdown menu called “Moving Platform”. Open this and you can disable all the “Floor Layers”. Ensure to expand the layers so you can see and disable all 32 of them!

This option seems to exist to allow smooth movement on moving platforms so the physics doesn’t get all jittery. However, it causes scenes containing CharacterBody2D nodes to stick together from above.

While I haven’t tried it, it’s also possible that changing the “On Leave” value to “Do Nothing” may solve the problem too.


Dude! I’ve been trying to figure this out for about two days. Thanks for your help!

1 Like

Glad it could help you!

A simpler change sufficed for me, that is changing that sticky CharacterBody2D’s Motion Mode to Floating. Thanks to you though, I’d scratch my head forever if not for your reply!


Ik this is very late but if someone finds this and needs help too, the solution that worked for me was going to the player node, then going to the inspector and to the menu “Floor”. There you have to set the Snap Lenght to 0. Hope this work out for others as well

While working, this won’t fit all cases. Might be ok for sidescrollers, but for top-down - not so much :thinking:

More appropriate solution is to refer to CharacterBody2D docs and use set_motion_mode() function (see MotionMode) and pick either MOTION_MODE_GROUNDED (for sidescrollers) or MOTION_MODE_FLOATING (for top-down).

Why setting snap length 0 “works”:

  • you essentially suggest CharacterBody2D code to “snap only things at distance 0” to floors
  • and since distance between objects is rarely (if ever) zero - it just doesn’t.

Hope that helps someone :slight_smile:

1 Like