Help in creating a custom movement system for a FPS game

I’m currently trying to make a custom movement system for my game using a combination of linear velocity and Raycasting to move the player. There will be mechanics like sliding, Vaulting, etc and I’m trying to make it somewhat similar to bad business.

However, I’m not too sure about this approach since the character collision interferes with the linear velocity when going down the slope (The character shakes when going down a slope) and I was thinking of making a custom collision hitbox like a bean but I don’t know how to implement it to the character.

Currently in used system:

It uses linear velocity and rotates the attachment based on the slope and player direction, detects slopes using by Raycasting downward every step.

	local Result = workspace:Raycast(HumanoidRootPart.Position, Vector3.new(0,-5,0), Params)

	if Result then
		local DotProduct = Result.Normal:Dot(Vector3.new(0,1,0))
		local angle = math.deg(math.acos(DotProduct))
		local angleRadians = math.acos(DotProduct)
		CollisionPoint.Position = Result.Position
		
		local playerForward = HumanoidRootPart.CFrame.LookVector
		local facingAngle = math.deg(math.acos(playerForward:Dot(Result.Normal)))
		
		local x, y, z = HumanoidRootPart.CFrame:ToEulerAnglesXYZ()
		local yDeg = math.deg(y)
		
		local normalHorizontal = Vector3.new(Result.Normal.X, 0,Result.Normal.Z).unit
		local crossProduct = normalHorizontal:Cross(Vector3.new(0, 1, 0)).unit
		local lookVector = HumanoidRootPart.CFrame.LookVector
		local angleT = normalHorizontal:Dot(lookVector)
		local perpDot = crossProduct:Dot(lookVector)
		
		if tostring(angleT) == "nan" then
			angleT = 1
			perpDot = 1
		end
		
		
		local AngleToBeAdded = (angle/math.max( (-angleT + 3) - 1, 1) )*(-angleT)
		--3 represents the percentage of the tilt
		--It basically prevents jumping when going up the slope
		
		local Yangle = angle * (-perpDot)

		
		attachment.CFrame = CFrame.new(Vector3.new()) * CFrame.Angles(math.rad(-90 + AngleToBeAdded),math.rad(Yangle),0)
	else
		attachment.CFrame = CFrame.new(Vector3.new()) * CFrame.Angles(math.rad(-90),0,0)
	end

Are there other ways to do a custom movement system? or ways to customize character collision?

2 Likes