Shapecast failing to detect certain parts

I am testing out the new Shapecast method for my Furniture Placement system and for some reason, it seems like it is failing to detect the floor, but will detect the Baseplate beneath that.

image

This is an image of the bed failing to attach to the floor beneath it, this system was working when I was using a different method but I wanted to opt for some new technology.

image

This is the bed now attached to the Baseplate beneath that floor. This only happens when the Baseplate is included in the RaycastParams.

I will paste the calculation function below in case anyone can spot any inconsistencies in my code.

local function calcPosition(): CFrame
	if not Mouse.Target then
		return nil
	end
	
	local size: Vector3 = Moving.Object:GetExtentsSize()
	local x: number, z: number
	local y: number = 5
	local offsetX: number, offsetZ: number
	
	if Rotation > 0 then
		offsetX = size.X * 0.5
		offsetZ = size.Z * 0.5
	else
		offsetX = size.Z * 0.5
		offsetZ = size.X * 0.5
	end
	
	x = Mouse.Hit.X - offsetX
	z = Mouse.Hit.Z - offsetZ
	local pos: CFrame = CFrame.new(x, 0, z)
	pos = snap(pos)

	Moving.origin.CFrame = CFrame.new(offsetX, 10, offsetZ)

	local included: {[number]: BasePart} = plrHouse:GetDescendants()
	shapecastParams.FilterDescendantsInstances = included
	local cast: RaycastResult = workspace:Shapecast(Moving.origin,-Moving.origin.CFrame.UpVector * 10, shapecastParams)

	if cast and cast.Instance then
		warn (cast.Instance:GetFullName())
		y = cast.Normal.Y
	end

	local finalCF: CFrame = pos * CFrame.new(offsetX, y, offsetZ)
	return finalCF * CFrame.Angles(0, math.rad(Rotation), 0)
end

The part is CanCollide, CanQuery, and CanTouch = true.
It was working at first, but I had to create a temporary shapecast part (the 0.5 transparent part) that was a clone of the Hitbox to properly raycast downwards. Otherwise, it would jump up and down attaching itself to the Baseplate and floor. Any ideas as to why it may not be working now?

1 Like