I'm working on a raycast-based vehicle in a 3D world using a physics engine. It's basically a chassis object that contains a transform (translation, rotation, scale), a dynamic rigid body (with mass, center of mass and other stuff from the physics engine) and 4 wheel children. Each wheel has its own transform, positioned where the vehicle suspension would be attached. It also defines suspension properties such as radius, spring constant, damper stiffness, etc.

Suppose I correctly calculate the spring force magnitude (the classic spring_force_magnitude = length_offset * spring_constant - spring_velocity * damper_stiffness). Now I need to apply the force as a vector with the correct direction. Also, forget about other forces such as acceleration or steering, I'm just trying to model suspensions here.

Here is a diagram that allows to explain my issue. The car is inclined and the ground is a slope. Only 2 (or even 1) wheel is in contact with the ground. It's a side or front view (doesn't matter) but suppose it's in 3D. Car diagram showing the world up, car up and hit normal vectors

So there are the world up (global Y), the car (or wheel) up and the raycast hit (the ground) normal.

Most tutorials (like the popular Very Very Valet video) use the car up vector. It seems logical since that's how the suspension spring is oriented. But when I use it and the car is inclined, it gets a force pushing it to the side. When I use the normal (like, I think, the DigitalRune vehicle) it seems to be too strong: the car jumps out because only 2 wheels are in contact. Should there be a factor that reduces the strength according to some sort of (which?) angle?

The question is: which direction? Car up, world up, ground normal, or a combination of those?

I use Rust with the Bevy engine and the bevy_xpbd physics engine but I don't mind any code that targets Unity, Godot or others.

  • 2
    \$\begingroup\$ Thinking of Newton may help here: which way is the road getting pushed? The push on the car has to be opposite that. \$\endgroup\$
    – DMGregory
    Mar 21 at 19:01
  • \$\begingroup\$ It's a good approach although all those angles confuse me. I'm not sure which way the ground is getting pushed. \$\endgroup\$
    – Splo
    Mar 22 at 8:04


You must log in to answer this question.

Browse other questions tagged .