Car StarterCharacter with slope physics (i need help)

i wanted to create startercharacter car with slope physics
and i need help, the car wont slope

and i tried with Character Controllers, alignorientation and it didnt work

anyone help?

1 Like

I dont recommend for you to use humanoids for cars, but if you really have to, raycast down and change the orientation of the car using normal, you gotta calculate the hip height too with this

2 Likes
1 Like

i might not understand, where do i change it and how?

1 Like

Humanoid.HipHeight

for the orientation then you’d have to use a Weld and change it’s C0 or C1 orientation

but don’t use a humanoid for cars

1 Like


i think i found some script to get the startercharacter car slope
heres the code:

local RunService = game:GetService("RunService")

local StarterCharacter = script.Parent
local Body:BasePart = StarterCharacter:WaitForChild("Body")
local RootJoint = Body:WaitForChild("RootJoint")

local RootJointC0 = RootJoint.C0
local RayParams = RaycastParams.new()
RayParams.FilterDescendantsInstances = {StarterCharacter}

RunService.RenderStepped:Connect(function(deltaTime)
	local RaycastResult = workspace:Raycast(Body.Position,-Vector3.yAxis*5, RayParams)
	local C0Offset = CFrame.identity
	if RaycastResult then
		local upVector = RaycastResult.Normal
		local rightVector = Body.CFrame.RightVector
		local backVector = -Body.CFrame.LookVector
		local calculationForX = CFrame.fromMatrix(Vector3.zero,rightVector,upVector)
		local calculationForZ = CFrame.fromMatrix(Vector3.zero,backVector,upVector)
		local x = calculationForX:ToOrientation()
		local z = calculationForZ:ToOrientation()

		C0Offset = CFrame.Angles(x,0,z)
	end
	RootJoint.C0 = RootJoint.C0:Lerp(C0Offset*RootJointC0,deltaTime*10)
end)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.