(Green being the “NextPos” (pos where next tile should go))
Here’s my code:
if previous then
local previousModel : Model = previous
local function ModelSnap()
local previousNextPos : BasePart = previousModel.PivotPoints:FindFirstChild("NextPos")
local selectedLastPos : BasePart = newSegment.PivotPoints:FindFirstChild("LastPos")
newSegment.PrimaryPart = selectedLastPos
newSegment.WorldPivot = selectedLastPos.CFrame
newSegment:PivotTo(CFrame.new(previousNextPos.Position))
end
ModelSnap()
end
(If you are wondering, corner tiles look like this:)
Assuming those paths are models, you could scrap the part thing and create attachments at the end of each model and also edit the pivot of the models, then you could simply change the models location to the attachment’s and have it work because of the pivot. And for the colliding issue I guess you could add a invisible hit box to when the next path is being generated, and detect if it hit anything you don’t want it to hit, and if it does you can regenerate a random path and check again if it colliding or not, keep doing that until you get a path that doesn’t collide .
Alright then. For the pivot thingy you can create an attachment at where the NextPos would be at ( the center of NextPos ) and change the model’s pivot to be placed at where the endPos would be at ( center of endPos ) and after doing that, teleporting the model to the exact position of the attachment would connect the two models