How to drag a custom collision mask inside another one?

How do I drag and keep an object’s custom collision mask inside another object’s custom collision mask? I’m trying to make an Isometric game where you have a floor that can change size (meaning multiple instances of the floor object connected with each other) and you have an item on the floor that you can drag inside that floor only and it should slide on the edges and follow the mouse smoothly. Both have a diamond/isometric custom collision mask. This is an example but it works with only one instance of the floor not many, and it is not perfect although it looks perfect. Please, help.

ezgif-3e270d389255e744

Can you post a image of the larger picture? How the scene is setup. Also, the events that you’re currently using.

It might be easier to add boundary objects to prevent movement. Or maybe use pathfinding instead of dragging. Or maybe, use a point on each side that detects whether there’s a tile?

It’s tough to say without more details.

I assume this is what you mean by the larger picture? keep in mind the floor can change size (expand and unexpand) it could also be not even i.e 2x8 or 8x2.
I managed to make it work with a single instance with this code:
Adding boundary objects but how am I going to make them adapt to the changing size i.e expansion ..
I’ve been trying to find a solution for weeks with AI too.

I’m not sure what part of this can help me? I don’t think my issue is similar to his 100% !

Ok ….have you tried using four custom points and checking point inside object? Id found that thread as I was curious to see whether there was an isometric auto tiling extension and that thread came up.
You could also possibly use an array and store the tiles and check that. I’d need to do this in order to check how it works with dragging though.

Yep, I am currently using 4 custom points but it only works with a floor that is made with one instance of an object not many instances I gave the code in one of the replies if you want to check it. As for the array option I’ll try but the issue is always I will expand and unexpand the floor and it is made with many instances of an object so I’m not sure if that will work out. This is like the most basic thing in isometric games yet it feels impossible lol.

what’s the mechanic you had in mind for changing the size of the floor?
this kind of works for point inside approach… but its a bit of an and or not headache! Its a tricky one due to it being dragged. so i used angle to cursor as a condition to check which way youre dragging it
![Screenshot 2026-08-16 223903|690x324]
(upload://3K3O6fBs1ZYat2VcZ79Q7KRe62Q.png)
isodrag
the drag logic needs a bit of work but its bedtime for me!

the mechanic for changing the size of the floor is like pressing 4 buttons to expand/unexpand from either bottom left or bottom right. It doesn’t matter, I just need it to work with multiple instances of the floor! It is a must that it drags smoothly and slides smoothly on edges. I wonder if you tested dragging the item on the edges, if it slides smoothly following the mouse or not!

Yes It works with multiple instances there’s two above. but I just woke up thinking ….what if all it needs is point cursor is inside floor.

i worked on it a bit. it does work just checking whether the cursor is inside the floor but its slightly better with points and the angle check. heres the example project with multiple floor tiles


that’s another thing .. it should work even if the cursor is outside! it follows the cursor even if the cursor is outside the floor.

Right …hadn’t realised that …thought you wanted to drag it.
You could do this instead


you need to left click to attract it
Might be worth trying pathfinding if the floors gets complicated- expand/unexpand the boundary object - Keith’s area of expertise.
edit - no it does work ok with more complicated floor
youll need to refresh the game window as it tends to load the old version

Not bad! I think I should have phrased what I wanted better. Yours does work but it is super slow and moves/drags in 4 directions only!
What I wanted exactly:

  1. An item that can be dragged freely in all directions and it follows the cursor even if it gets outside the floor.
  2. The floor is made of multiple instances connected together. They form a diamond shape and they have a custom diamond/isometric collision mask.
  3. the item must be dragged smoothly on the edges.
  4. the item’s collision mask mustn’t be touched because it determines where I can grab it and I want to grab the whole item.
  5. the item’s base must always stay inside the floor, the item base will be a diamond/isometric shape probably made with points.
    I hope this is better? Thanks by the way for replying and trying.

ok - try the link again - I use this at the start to create wall objects around the perimeter


then used separate objects and force towards cursor
points 1 to 4 are outside the faces of the floor object and 5 to 6 are the corners
you might need to click the link a couple of times to get the latest version

i just changed it so it slows down as it gets near a wall …raycast towards cursor and use that distance for the force but clamped 20,400

not bad at all! Is there a way to control the speed? it feels very slow? but you pretty much nailed it!

the speed is this expression ..so play around with that. The points on the shapes are a bit off but it should work smoothly once its set up right.

could you send me the full code to try it? I think there are some numbers based on objects sizes which are different than mine. thanks a lot by the way for your time solving this. I essentially gave up and decided to use one big floor object to represent the floor, but now considering your way.

I wanted to try the math version. It’s late and I’m tired but I got it to work. So, I wanted to post it. I apologize for any typos.

If you convert the isometric position to cortesian then you can clamp the value because it won’t be rotated or at an angle. You can then convert the values back to isometric.

I tested it with 3 objects. A player object that I dragged. A testPlayer that displayed the cortesian values. And a testPlayer2 that shows the clamped position. If it wasn’t so late I wouldn’t have converted it to just variables but I love the visual version. It makes it easier to debug.

My events

I created my own functions. I passed them the X and Y.

From ISO x to cortesian

From Y

Back to iso X

Back to iso Y

The functions aren’t really needed but I thought they might come in handy later plus it simplifies the main sheet.1

Calculating the clamp numbers shouldn’t be too difficult but it’s late and my brain no work. I used a text object to display the numbers and added them to the clamp.