Need help balancing a VehicleBody3D that has 2 VehicleWheel3D (AKA a bike)

Godot Version

4.3

Question

Hello!

I’ve been trying to make a bike using the Vehicle nodes, but I’m having lots of troubles making it not fall over at the slightest movement.

So far, I tried these methods:

  • Locking the bike’s rotation on the Z axis (rotation.z to 0.0 on every physics frame) → the bike slides weirdly on the ground
  • Locking the angular velocity on the Z axis (angular_velocity.z to 0.0 on every physics frame) → it becomes extremely hard to make a turn
  • Different variations of applying torque (and torque impulse) to the bike when it’s not standing straight → the bike jumps around violently or the force is not strong enough to compensate the fall
  • Enabling the axis lock: angular z property on the VehicleBody3D → same problem as locking the angular velocity on the Z axis (probably because it does the same as what I did manually)
  • Lowering the center of gravity → the bike bounces around weirdly, but at least it doesn’t fall

Here’s the node setup:

image

The front wheel is used as steering, and the back wheel is only traction.

Thanks for your help!

https://www.physics.utoronto.ca/~jharlow/teaching/everyday06/reading07.htm

The most important factor in handling is trail, which can be thought of as the extent to which the front wheel of a bicycle follows its steering axis.

Try adjusting the trail.

You have to first turn the handle bars right a little, to cause you lean left and then steer left (and vice versa).

I believe this is also tied to the “trail” and adds to the overall stability.

Not an expert tho.