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.