0 votes

I'd like to develop a 3D vehicle with 2 wheels, in other words, a motorbike.

I tried to implement that by locking z axis rotation, but the problem here is that it seems to lock not on relative node'z axis, but rather the origin's, I'm not sure if that's correct, I'm investigating.

I also tried to simulate counterbalance by rotating along the z axis proportionally to steering and speed, with something like:

var inclination = atan(-steer_angle * _state.linear_velocity.length())
self.rotation_degrees.z = rad2deg(inclination) 

but, even if it lean the bike in a semi realistic manner, it seems to rotate not taking into account forces, so tha the bike somehow falls in a weird way. It might be that I should not rotate along an axis but rather apply a torque, I have to try this.

My idea was that I have to move the center of mass by rotating the VehicleBody along Z axis so that the centrifugal force is balanced by the resulting vector of mass center - floor constraint (remove the y element), as I tried to illustrate below.
But the problem is that I can't find a method that gives me the centrifugal force, I'm not even sure if it exists.
Bike Forces
Well, I'll surely continue investigating, there might not be a function that does that but maybe I can calculate it manually.
If someone in the meantine finds, or have a solution already, I'll be glad to be enlightened.

in Engine by (106 points)
edited by

Did you ever find a solution to this issue?

I am currently trying to build a motorbike and the thing keeps swaying like a boat!

Please log in or register to answer this question.

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.