+1 vote

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?

in Engine by (34 points)

1 Answer

0 votes
Best answer

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:
https://github.com/WheelOfPython/Hill_Climb_in_Godot

Tweak the parameters to get better results.

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

by (34 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.