Currently my placement system relies on a single part (the black part, named ‘Base’) which basically goes from edge to edge of the house, howeverm if the house has areas that jut out (pictured below) then the object can be positioned thru the walls and then into the ‘void’
Theorising here, but could it work if just set the ‘base’ as the mouse.Target?? like
if mouse.Target.Name == 'Base' then
Base == mouse.Target
end
And then I have half a dozen parts be the base??
Nevermind, that wouldn’t work, as if two bases are connected to each other then the part would jump from one base to the other.
Could there be a way instead to just prevent the model from ever entering the wall?
local LowerX, UpperX, LowerZ, UpperZ = CheckBase(PlayersPlot.Base)
local Item = cateogry:FindFirstChild(item)
if not Item then return end
local ItemClone = Item:Clone()
if not ItemClone then return end
ItemClone.Parent = PlayersPlot.Camera
mouse.TargetFilter = ItemClone
RenderStepped = RunService.RenderStepped:Connect(function()
RenderPosition(PlayersPlot, mouse.Hit.p, ItemClone, LowerX, UpperX, LowerZ, UpperZ)
end)
CheckBase function
return function(base)
local LowerBoundX = base.Position.X - (base.Size.X / 2)
local UpperBoundX = base.Position.X + (base.Size.X / 2)
local LowerBoundZ = base.Position.Z - (base.Size.Z / 2)
local UpperBoundZ = base.Position.Z + (base.Size.Z / 2)
return LowerBoundX, UpperBoundX, LowerBoundZ, UpperBoundZ
end
RenderPosition
return function(playersPlot, mouseP, object, lowerX, upperX, lowerZ, upperZ)
local MouseClampedP = ClampMouse(mouseP, lowerX, upperX, lowerZ, upperZ)
local Size = object.PrimaryPart.Size
if not Size then return end
object:SetPrimaryPartCFrame(CFrame.new(Round(MouseClampedP - Vector3.new(Size.X / 2, 0, Size.Z / 2), 1, playersPlot.Base.Position.Y + (Size.Y / 2))))
end
I tried to just post the necessary scripts, as there a lot to this.