Trouble with Raycast Vehicle Sliding on a Slope

I want to apply a brake force so that I have control over the vehicle’s sliding. However, any attempt to do so just isn’t enough to stop the vehicle or too much of the effect where the vehicle slides upwards.

In this video, I’m trying to brake using the vehicle’s velocity times a multiplier.


Notice that the vehicle still ever so slightly slides down the wedge.

I’ve also tried calculating a slide prevention force by projecting the vector to the plane with this set of functions:

function utility.projectVectorToVector(vectorToProject: Vector3, vectorToProjectTo: Vector3): Vector3
	local unitOfVectorToProjectTo: Vector3 = vectorToProjectTo.Unit
	local projectedVector: Vector3 = vectorToProject:Dot(unitOfVectorToProjectTo) * unitOfVectorToProjectTo
	return projectedVector
end

function utility.projectVectorToPlane(vectorToProject: Vector3, planeNormalVector: Vector3): Vector3
	return vectorToProject - utility.projectVectorToVector(vectorToProject, planeNormalVector)
end

function utility.getGravitySlidePreventionForce(mass: number, surfaceNormal: Vector3): Vector3
	local gravity: Vector3 = mass * Vector3.new(0, -workspace.Gravity, 0)
	local gravityProjectedToPlane: Vector3 = utility.projectVectorToPlane(gravity, surfaceNormal)
	return -gravityProjectedToPlane
end

No matter what, despite being the correct numbers, applies too much force upward for the Vehicle.

I’ve ran out of options and solutions. If someone could help me, it would be a blessing.

To add, the raycast vehicle uses vector forces to lift the vehicle upwards.

Does the mass include the mass of the play ontop of the car? or only the car mass?

Uses assembly mass so the player ontop of the car.

Bumping. Any possible solutions?

This issue has been resolved because I switched to using constraints instead. Thank you Devforum.

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