Hello, fellow scripters. I’m making this topic, because I am stuck with a current issue.
I’m working on a grid based - block building system but it’s not working as it should. I am currently using raycasting and normal vectors to detect which surface your mouse is on. This works perfectly fine for some of the axises, but for some reason it offsets way to much on other.
I can see you have made it so the block doesnt interfear with your mouse thats good.
If your going on a grid system id round your mouses position to the nearest increment you are using, e.g to nearest 4. Make sure this means you wont need to offset and it will appear to snap to the nearest grid point
basically just round it. Theres no need for it to be far from the mouse
the reason why its doing that is because your adding a CFrame to it creating a gap.
if the mouse moves and you have rounded it, it will go to the closest grid point.
So if there is a block and you click the side of it and your blocks and grid are set to 4
you are clicking on the side of the block so it will be closer to where you want it and wont make blocks inside blocks
Thanks alot for taking your time. This is the current way I’m approaching it on the server. I’m rounding the X,Y,Z axis with a gridsize of 3. Where exactly should it be rounded again? Sorry if I misunderstood you.
It should round to half the size of your blocks.
Because when setting position the middle of the block is placed, so you might need to take that into acount.
Im not 100% sure because I cant test it right now and i need coffee.
it will either be the same size or half, either way its not complicated to change
adding a small number to get it into the correct grid reference seems like a good idea.
although if its in the negatives and your on the side of a cube it could force it into the wrong grid ref
id make a 3d representation of a 3d grid. also compare the click position with the position its placed in. that way we can see where parts are falling out of place.
You could also change the transparency so you can see how much is overlapping
so basically if you rounding to every multiple of 3, set a tiny block at every multiple of 3 in a little area. then you can clearly see it filling space. if it constantly places in the correct area then it works