Downforce on raycast suspension car

I currently have a car which uses raycast/scripted suspension to stay up and an AlignOrientation to orientate itself to the ground below. I have a problem where the car’s suspension raises when it’s driving over a hill at high speed.


Normally I would fix this using downforce; however doing so on what essentially is a floating brick brings it down by quite a lot, and I don’t know how to go around this. If there is any other way of preventing my issue from happening? I have tried manually clamping the car’s Y velocity based on its’ velocity in object space, however this does not seem to help.

1 Like

Forgot to mention, but the only thing that seems to help this is maxing out the Gravity of Workspace, however that obviously comes with many downsides and I would prefer not to use this method.

You need to multiply your damping vector by the raycast normal.

1 Like

Already doing that. The issue does not come from the suspension itself, it’s just a natural physics occurence

Interesting. Last time I checked, my raycast car does not have that issue. You can possibly try using a vector force to apply artificial gravity on the car.

It just comes with speed, the car is travelling at a magnitude of ~300 and there isn’t enough gravity force pushing it down, if the ramp had been any sharper it would have just done a jump. I’m trying to find a way to apply downforce so that this doesn’t happen (obviously without messing up the suspension height)

Pretty much what I’m trying to do, however adding a downwards force strong enough to counteract the forces causing the issue brings the car down, raycast suspension is pretty much a hovering script after all

Alright. Is your raycast car using the normal for the lift force or just the global Y axis? I’ve used mine with the Y axis and it seemed to have this issue before I changed it to the normal of the raycast.

Here is the spring code:

local springDir = sray.Normal
local worldVelocity = car:GetVelocityAtPosition(v.WorldPosition)

local rayDistance = (v.WorldPosition - sray.Position).Magnitude
local offset = (springLength - rayDistance)

local velocity = springDir:Dot(worldVelocity)
local force = (offset * stiffness) - (velocity * damping)

v.Spring.Force = springDir * force
1 Like

What exactly is the value of damping? This code seems fine.

Stiffness divided by 10, the code is fine

Alright. What happens if you apply force relative to the raycast intersection position instead of relative to the car?

If you mean raycast.Position the car just flings, if I multiply Force by Vector3.new(0,1,0), the suspension only works on straight/non-angled surfaces.

Interesting. Does making it relative to the wheel have any different results?

1 Like

Nope, nothing changes, issue still present

Very weird. In my car, I just reduced damping and it seemed to fix that problem. You could try taking the dot product of the normal and the car’s velocity to calculate some sort of downforce.

Did you try making your car go at around 300 speed?

My car goes about that fast. However, to go those speeds the damping needs to be quite low so it doesn’t glitch out.

Mine uses a BodyGyro to orientate itself, so I’m guessing this happens because the gyro doesn’t keep up when the car is going that fast

This is most likely the case seeing as this issue only occurs at high speeds