Raycast suspension car unstable on edges

I have a raycast suspension car that currently jitters when it’s driving across an edge with 2 of its’ wheels in the air. Here is how it looks:

The spring code:

local velocity = springdir:Dot(car:GetVelocityAtPosition(fa.WorldPosition))
local offset = (rideheight-ray.Distance)
local force = (offset * tune.springstiffness) - (velocity * tune.springdamping)

No clue what causes this honestly. Any help is appreciated.

2 Likes

Raycasts are 1-dimensional lines so the collision detection is bound to be very buggy. One moment it’s on flat ground, but if you drift 0.1 studs then you’re suddenly in midair. Try using shapecasts instead; the new generalized shapecast was just released recently and you can use the entire wheel model as the casting shape.

1 Like

I don’t think the single raycast is the problem here, I’ve seen car games with single-raycast wheels that don’t have this problem at all

1 Like