I've been stuck on this for almost too long if not too long, & I've tried putting together a 3D grid placement system where blocks can be placed on other blocks' surfaces no matter the rotation of shape of the object. I'm pretty much trying to recreate the original stamper tool placement system, but there's always something in the way. I tried using rays and other strategies but it seems to always break and it's pretty irritating.
There's a tool in the starterpack that is responsible for moving and placing the block (just for testing) which is:
function HoverPlacementLoopFunction(Model_ID) Mouse.TargetFilter = PlacingModelObject.Value local newRay = Ray.new(workspace.CurrentCamera.CFrame.Position, (workspace.CurrentCamera.CFrame.Position - Mouse.Hit.p).Unit * -200) local _Part,Position,SurfaceNormal = workspace:FindPartOnRayWithIgnoreList(newRay, {Player.Character, PlacingModelObject.Value}) local newPosition = CFrame.new( Ceil((Position.X + SurfaceNormal.X) / PlacingModelObject.Value:GetExtentsSize().X) * PlacingModelObject.Value:GetExtentsSize().X, Ceil((Position.Y + SurfaceNormal.Y) / 4) * 4, Ceil((Position.Z + SurfaceNormal.Z) / PlacingModelObject.Value:GetExtentsSize().Z) * PlacingModelObject.Value:GetExtentsSize().Z ) PlacingModelObject.Value:SetPrimaryPartCFrame(newPosition) end
It's snapping to the grid, however it is floating off the ground & when i try to place it on one side of another part, it works as expected, however if i try to place it on the opposite side of that block it acts as if it isn't even there and doesn't snap to the side of the part.
My question is how would I make a reliable placement system is friendly to all block sizes 90/180 degree rotations and actually works?
I've tried using **TargetSurface **to make it work properly based on the rotation too, but that didn't work.