Is there a WheelJoint2D?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By User1011

Using Godot 3.1
I’m trying to replicate the Hill Climb game car physics, but I can’t use the 2d spring as a suspension, as it can not be constraint in one axis (the local Y of the vehicle).

I tried to use it in combination with a groove joint, but it doesn’t make any difference, as it rotates around the connection point too.

In my understanding, this is a limitation of the engine and can not be resolved even with some kind of script in the spring node.
In Box2d and Unity there is a WheelJoind2D and Godot seems to have one for 3D…

Is there any way to use a spring 2d only in one axis and more specifically as a suspension?

:bust_in_silhouette: Reply From: User1011

I used multiple carefully positioned physics nodes and managed to get the restriction on the Y axis.
Basically I used 2 GrooveJoints to restrict the wheel on the Y axis and then connected it to a spring.
Doing it directly though, the wheel’s rotation would rotate the whole car, so I used 2 rigid bodies as inbetweens to let the wheels spin freely.

Here is the Project:

Tweak the parameters to get better results.

Note: I use the default icon as texture, so make sure to enable ‘Visible Collision Objects’.