Need help with collision detection for a model placement system

So I’ve been working on a model placement system recently. But I am having some trouble triyng to get collision detection to work.

It seems my current method for collision detection isn’t reliable. As shown in this video:

It’s kind of a hit or miss. Which is not good.

So I now need a new way of checking collisions when building, but I can’t seem to find anything online to help me with my case.

So some help would be greatly appreciated. Thank you!

local function GetTouchingParts(PrimaryPart)
	local connection = PrimaryPart.Touched:Connect(function() end) -- This allows for parts with CanCollide false to work with GetTouchingParts()
	local results = PrimaryPart:GetTouchingParts()
	local FilteredResults = {}
	for i, Part in ipairs(results) do
		if Part.Parent and Part.Parent ~= PreviewModel and Part.Transparency < 1 then -- Make sure that the part(s) we are hitting is not in our model
			FilteredResults[i] = Part
		end
	end
	
	connection:Disconnect() -- We no longer need this connection.
	return FilteredResults
end

Hello, I don’t think using :GetTouchingParts() is good idea, since it works only if object has the collision. I would recommend using RotatedRegion3 module by EgoMoose: Rotated Region 3 Module

1 Like

Wow. I gotta say, @EgoMoose’s work can be really impressive sometimes.

Thank you for showing me this module! This just saved many hours of pain.

No problem, I had the same issue a long time ago.

1 Like