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.
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.
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.
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
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.
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.