Hey, I’m making a placement (building) system.
For now, each item can be placed on 1 block (foundation).
The code I made:
local surface = Mouse.TargetSurface
local modelSize = targetModel:GetExtentsSize()
local modelCenter = targetModel:GetBoundingBox()
-- placeability checks here
surface = surface.Name
local vecCorrection =
surface == 'Top' and Vector3.new(0, modelSize.Y , 0) or
surface == 'Bottom' and Vector3.new(0, -modelSize.Y, 0) or
surface == 'Right' and Vector3.new(modelSize.X, 0, 0) or
surface == 'Left' and Vector3.new(-modelSize.X, 0, 0) or
surface == 'Front' and Vector3.new(0, 0, -modelSize.Z) or
surface == 'Back' and Vector3.new(0, 0, modelSize.Z)
selectedItemModel:PivotTo((modelCenter + vecCorrection) * CFrame.Angles(0, math.rad(currentItemRotation), 0))
However, this basic placement system is not enough for some of the items.
There are items that are too big for only 1 block.
Here’s an example of what I mean: https://gyazo.com/d22ae87d6e6d8281443692561fa9d50a
What I want to achieve is to have a bigger grid for some of the items, if that makes sense.
So, if I picked a big item, I want the grid to look like so:
And then, if I hover my mouse on any of the blocks in the group, it should automatically set the item position to the center point of the group:
Sadly, I don’t have any idea how to go about detecting the groups.
Spatial queries could be an option but then the groups would mix up.
I would appreciate any help!