Any way to round to a 2x2 tile

I have a system-
That causes objects to fix into every tile, but since In a new game everything is in 2x2 squares i’m not sure how to make them adjust to that, since they move per individual tile.

1 Like

make sure you run them through number blocks. number blocks have the ability to round up, down, or regular rounding. you should be able to do the rest of the math yourself

That’s not the rounding i need, I need it to center itself within a 2x2 area.

ah alr, I would reccomend doing this:
divide the number by 2 → round the number with a number block → multiply the number by 2.

This will give you an output that is a multiple of 2, each time :slight_smile:

EDIT: you can also divide the number by 128, round, multiply by 128, which will give you an output that’s a multiple of 128. any number works

So i messed around with this, the best I get is that it does what I want, but also goes in between the two tiles
I made all the divides and multipliers (32)
Because 128 made it center between 4x4, and 64 was just very strange.
(Is there a way to make a filter for only even numbers?)

are you making a drag-and-drop system by chance? and also, 64 is needed for a 2 tile big grid (ik youre aware of this, but just saying)

I am making a drag and drop, like Plants Vs Zombies if you’re familiar.
It’s also offset from the cursor by like 120 lol

alright, got it. I have an “is even” filter in one of my games, but it just outputs 0 or 1. I think @JR01 will probably know more about making a filter for even numbers though.

1 Like

Should Math.floor(A/64)*2 work?

Doing that is the closest so far, but it’s a little offset

1 Like

Ah yeah, try this Math.floor((A/64)*2)

No difference, I could Possibly add to it, so that it fits where it should?
I’m very bad at using expressions

Are you spawning at (352,288)?

(This would be (5,4)*64+32)

This is the full thing right now, the position is set to grid.

Your game doesn’t look 64x64 with that white line.

Ive gotten it back tot where it needs to be filtered from even and odds for it to work perfectly fine.
It is 64x64, that line is just a 32 wide.
Screen Shot 2023-01-19 at 1.43.40 PM

1 Like

You were right @The_KWASM, I’m doing some testing.
The problem was that because the object is 64x64, the center of the object is still in the 32x32 grid shape. So you have an offset of 16 pixels outside off the center of the object compared to the grid.

Below is the new formula, but you have to set the position to pixels.

Well now it doesn’t adjust at all, it’s just adding 32.

What do you mean by that?