{still no fix :*} Placement system - collision script not working properly?

I didn’t think about that, in that case it could be a issue with FindPartsInRegion3WithIgnoreList because your code looks fine.

yea, also the glitch only occurs when both hitboxes are the exact same size. if you try to place a smaller item inside of a bigger item, it wont work.

Yea so its def a FindPartsInRegion3WithIgnoreList glitch.

well, not much i can do about it then. i guess ill just wait for roblox to fix it

1 Like

Not a solution but more a suggestion. I’d rework your logic and map the entire base into a matrix instead. This would make it very easy to keep track of where your objects are located at and where you can’t / can place them.

Here’s a more feasible solution:
https://developer.roblox.com/en-us/api-reference/function/BasePart/GetTouchingParts
As you can determine if a part is within / intersecting another part.

So based on that, I’d generate a temporary part the size of the model using:
https://developer.roblox.com/en-us/api-reference/function/Model/GetBoundingBox

And then use the GetTouchingParts method (unless you can directly do it with the model itself).

2 Likes

You might want to use something like: https://developer.roblox.com/en-us/api-reference/function/BasePart/GetTouchingParts

Also I noticed the size you are searching is smaller hitbox.Size-Vector3.new(0.1,0.1,0.1), try using the normal size.

For debugging you can create a part and:

viewer = Instance.new("Part",workspace)
viewer.CFrame = RR3.CFrame
viewer.Size = RR3.Size

To see where the Region spawns in at

Use GetTouchingParts

local function GetTouchingParts(part)
	local connection = part.Touched:Connect(function() end)
	local results = part:GetTouchingParts()
	connection:Disconnect()
	return results
end

local function CheckCollision(instance) 
	local IsColliding = false
	if instance:IsA("Model") then
		for _,z in pairs(instance:GetChildren()) do
			local result = GetTouchingParts(z) 
			for i,v in pairs(result) do if v:IsDescendantOf(instance) then table.remove(result,i) end end
			if #result ~= 0 then
				IsColliding = true
				break
			end
		end
	end
	if instance:IsA("BasePart") then 
		local result = GetTouchingParts(instance)
		if #result ~= 0 then IsColliding = true end
	end

	return IsColliding
end

but it doesnt return parts with cancollide off right

Would this workaround solution solve that?

mm that looks interesting let me try it out

1 Like

nope the same issue is still there

Either make the actual region bigger than the bounding box, or raycast from above the object downwards to see if it hits something.

i dont think it would work with a 3 dimensional map tho

Personally i solve this by using :GetTouchingParts() and checking with it every frame while placing an object.I solve the CanCollide problem by turning on collisions right before running the check and then turning it off immediately after.

Here is an example that i use and it works perfectly:

CanPlace = true
GhostObj.Base.CanCollide = true --GhostObj is the clientside object that i move, Base is the "hitbox".
for i,v in pairs(GhostObj.Base:GetTouchingParts()) do
	if not v:IsDescendantOf(GhostObj) and v ~= workspace.Baseplate then
		CanPlace = false
    end
end
GhostObj.Base.CanCollide = false

if CanPlace then
print("object is not colliding with anything")
end

I obviously recommend doing this same check on the server, once the player places the object. Can’t trust the client.

Hope this helps!

thanks for the reply, i do appreciate any help at all, but i have already tried and got the same result :confused:
but ill still try again just to make sure it doesnt work

You’re shrinking the size of the region to check in by v3(.1, .1, .1). I’m not sure how your Rotated Region3 module works, but it might be failing to detect the collision when both props are in the identical spot because the hitbox faces are outside of the region. (Which would be expected if the module uses raycasting for collision detection)

I use AxisAngle’s Rotated Reg3 module for placement detection. It has similar functionality to the rotated region3 module you used, but correctly detects a collision even if the part’s faces exceed the region bounds.

The syntax translates as

local region = RotatedRegion3.new(hitbox.CFrame, hitbox.Size)

local collisionParts = region:Cast(ignorelist)

for _, part in ipairs(collisionParts) do
    if v.Name == "Hitbox" and v ~= hitbox then
	canPlace = false
    end
end

As an optimization for my placement system, I use region:CastParts(parts) to do a whitelisted collision check, instead of the blacklisted ignore approach. parts would be an array of all the already placed hitboxes.

1 Like

sounds promising, ill try that out soon and post the results.

1 Like

wow. thanks. you have fixed an issue i was struggling with for like over 3 months now

1 Like

You’re welcome; glad I could help.

1 Like