Wacky Collison

Video

local function handleLevelCollisions(self, normal, distance)
	if normal == nil then
		print("Error: normal is nil")
		return
	end

	distance = math.abs(distance) * vmath.length(normal)
	print("Distance abs:", distance)
	
	if distance == nil or distance <= 0 then
		print("Error: distance is invalid:", distance)
		return
	end
	print("Distance:", distance)

	distance = distance * vmath.length(normal) --normal dist compensation

	if distance > 0 then
		--project accumulated correction onto the penetration vector
		local projection = vmath.project(self.correction, normal * distance)
		if projection < 1 then
			local compensation = (distance - distance * projection) * normal
			go.set_position(go.get_position() + compensation) -- apply compensation
			self.correction = self.correction + compensation
		end
	end

	local normalLength = vmath.length(normal)

	if normalLength > 0 then
		self.vel.x = 0
	end

	if math.abs(normal.x) > 0 then
		self.vel.x = 0
	end
end

Debug outputs

DEBUG:SCRIPT: Received normal: vmath.vector3(-1, -0, 0)
DEBUG:SCRIPT: Distance abs: 279.43923950195
DEBUG:SCRIPT: Distance: 279.43923950195

I am not sure why this is happening. I think it may be overcorrecting with the normal.
Thank you for your assistance.