Roblox's Shape casting methods weirdly unprecise

I understand where you’re coming from, but i like to inform about stuff like that just to make sure anyone else can find this thread later if they cant find it in the discussion category anymore & want to check up or whatever.

1 Like

So a physics things then I am assuming?

1 Like

He just said it’s an issue with how he implemented his skin. Anyways, implementing skin is effectively impossible currently. If you expand your shape by your skin amount, it doesn’t actually solve the issue of shapes being too close clipping; it just makes your shape bigger, not to mention you can’t easily expand all shapes. If you want to shift back from your hit destination, that’s not feasible either. The amount you need to shift back along your velocity depends on the angle at which you collide with an object. You can’t know what that angle is unless you collide with it, and you can’t ensure you collide with it without extending your cast by that distance.

1 Like

If your looking for a movement system using shapecasting you have realized its not possible at the moment. What I decided to do was rip chickynoids collision system and just use it for my own movement controller that’s client sided. Its pretty easy to do and I’m current working on it right now, I was even able to add different sized casting. If you need any help I can always share my version of the collision system and help you set up a custom character controller.

1 Like

You can’t implement skin properly, but you can still use shape casts for collision detection. Instead of shifting the character backward from the hit location, shift the shape cast’s origin backward. As long as there isn’t anything between your shifted back position and your actual origin, the outcome will be the same, but you don’t need to worry about being too close to a target. It probably isn’t the best solution, but I currently use it for Chickynoid, and I haven’t had any issues. Here’s the module I made for Chickynoid if you want to look at how I did it. A shift back amount of 1 works well for the 2x5x2 characters I use; you have to make sure the shifted origin is contained within the current character

local function newSweepInfo()
	local info = {}
	
	info.startPosition = Vector3.zero
	info.endPosition = Vector3.zero
	info.fractionTraveled = 1
	info.startedSolid = false
	info.completelySolid = false
	info.normal = Vector3.yAxis
	info.instance = nil
	
	return info
end

function module:SweepBlock(startCFrame:Vector3|CFrame, endPosition:Vector3, size:Vector3, doShiftBack:boolean, collisionGroup:string)
	local sweepInfo = newSweepInfo()
	
	if typeof(startCFrame) == "Vector3" then
		startCFrame = CFrame.new(startCFrame)
	end
	
	sweepInfo.startPosition = startCFrame.Position
	sweepInfo.endPosition = endPosition
	

	local offset: Vector3 = endPosition - startCFrame.Position
	local distance = offset.Magnitude
	local direction = offset.Unit
	
	local shift = doShiftBack and SHIFTBACK or 0
	
	if distance <= 0 or distance+shift >= 1024 then --INVALID CAST
		--warn("INVALID CAST DISTANCE")
		sweepInfo.endPosition = sweepInfo.startPosition
		return sweepInfo
	end
	
	local blockcastParameters = RaycastParams.new()
	blockcastParameters.CollisionGroup = collisionGroup or Enums.CollisionGroups.Character
	
	local blockcastOrigin = startCFrame - direction*shift
	
	local blockcastResult = workspace:Blockcast(
		blockcastOrigin,
		size,
		direction*(distance+shift),
		blockcastParameters
	)
	if not blockcastResult then -- NOTHING HIT
		return sweepInfo
	end

	
	sweepInfo.fractionTraveled = math.clamp((blockcastResult.Distance - shift) / distance,0,1)
	sweepInfo.normal = blockcastResult.Normal
	sweepInfo.endPosition = blockcastOrigin.Position + direction*blockcastResult.Distance
	sweepInfo.instance = blockcastResult.Instance
	--sweepInfo.completelySolid = sweepInfo.fractionTraveled < 0.001
	
	return sweepInfo
end

That reminds me i did see your reply on the chickynoid post. I already tried your solution but when you walk up to walls at a certain angle you can still clip through them. It’s just an issue with how shape casting works at the moment. That’s why i have to resort to using chickynoids collision which i don’t mind

What angles were causing it? I have changed the module since I posted it in the Chickynoid forum