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):
    update_sprite_animation.rpc("idle")
    velocity = Vector2(0,0)
  else:
    update_sprite_blendposition.rpc(move_vector)
    update_sprite_animation.rpc("walk")
    velocity += move_vector * MOVE_SPEED
1 Like
: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.

2 Likes

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.

2 Likes

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!

1 Like