Prevent objects from crossing each others

I’m using draggable behavior and separate objects in event but when I drag object toward an other that suppose to stop it ,it don’t

Can you screen snip the events so we can see what you’ve done so far?

I will but how to upload and add a video to topic to make it clearer?

Its actually pretty easy.Just Put the platform and the platformer character behaviour on the sprite.This will make it think that the sprite is a player and also a platform, preventing them from colliding or Phase through.
WARNING:Dont forget to change the gravity in platformer character behaviour to 0 or else your objects will fall down in preview.
WARNING:This method is not very efficient so please do expect some glitches:)

Make sure the separate objects action is in an event that runs on every frame. So an event with no conditions should do the trick.

thank you insein
I’ve already did that… not working

thank you for the idea
I tried it … same result

I’ve tried physics behavior which is the best thing I love about :logo_gdevelop:
but it makes a pixel or two between objects so that makes it not working correctly in this case
images are for normal dragger behavior
2024-03-09 17-42-29

The problem you’ve got is that the drag behaviour will move the objects to be under the mouse. When the mouse is past the middle of the border, the tile is moved to the other side of the border.

OHHH now i get it the problem is the way you use the behaviours.i will give you the solution is a few minutes untill then please enjoy this game made by me:)

its not only that… look at block 7 in gif, it ran outside because his brothers pushed him :grin:
I’ve tried other methods like adding force to cursor, magnet extension, platform behavior
all same result because like you said its updating position information every frame so separate event wouldn’t work correctly, the only way to do what I want is to drag tile as physical object it wouldn’t cross others even if cursor is out but physics behavior makes a small space 1pixel or 2 between objects and that makes another issue even if bullet option enabled or collision mask edited
I want to learn how to make tiles draggable just like it is puzzle game real life .

Have you tried drag with physics extension

I think that, because you’re after some more specific dragging action which the dragging behaviour isn’t designed for, you will be better off coding the series of events yourself.

This will involve keeping track of the change in mouse position when a tile is clicked, determining which direction the mouse is moving, and checking whether the clicked tile can move in that direction.

1 Like

With your inspiration, I’ve created an example project that should help.

1 Like

sure, that was the 1st try
yes you’re right, thx for the idea of detecting mouse direction
nice, I like the idea of moving rows :+1:

1 Like