confusion about VehicleBody

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

I am trying to create a driving mechanic but I just cannot seem to make the vehicleBody node work. Here is my setup:

I created a world scene that has a CSGBox with the collision enabled, just to have some kind of floor.

Then I created another scene that has a VehicleBody as the root node and 4 VehicleWheels as children, with each of them having an appropriate Mesh attached. The mesh for each wheel is a child of the respective VehicleWheel node, they are in the same place and the only attribute I changed of the VehicleWheel nodes was the radius to make them the same size as the wheels.

This scene was then instanced into the level scene. (I also added a camera, but I suppose that doesn’t matter to the car)

Once I tried to run all of this I encountered a lot of problems:

First, the body of the car would be too heavy and drop all the way to the floor. Also, the wheels would clip partially through the floor. I tried to address this by adjusting the rest length of each wheel. This did make the wheels kinda work, although each wheel would still clip through the floor a tiny bit. But now the car would be very unstable and tilt forwards. Especially confusing was that even though the different wheels had the same rest length, the car still wobbled forwards.

I tried to play with the other attributes of the wheels, but none seemed to fix the issues and there doesn’t seem to be a detailed guide on how the VehicleBody works, or at least I couldn’t find one…

My questions would be:

  1. Does the radius of the VehicleWheel node need to be the same as the mesh it surrounds and does it need to be in the center of it (as opposed to being on the outer or inner side of it)?
  2. Did the car in my game wobble because I need to experiment for each wheel’s rest length and find the perfect balance or is there an easier way?
  3. Is there a decent guide online that explains how the VehicleBody works? That would be insanely helpful.

Edit: Here are pictures of my setup

Car scene

Game result

Instanced scene

Hi,
can you provide a screenshot of the setup and of the sceneTree? With the given informations the answer can only be very vague.

klaas | 2020-09-27 17:54

Hi, thanks for the help.

Here are the pictures of the setup and the game result:
Engine: car hosted at ImgBB — ImgBB
Level: level hosted at ImgBB — ImgBB
Result: game hosted at ImgBB — ImgBB

1izNoob | 2020-10-01 09:40

just figured out how to add images, they are added now to the original post :slight_smile:

1izNoob | 2020-10-01 09:51

I have the same issue. Have found an answer to your Q? I watched the samevideo and even downloaded the guys version from github. It has this problem too. I am thinking maybe this is an environemtn related problem.

istemihan | 2021-05-09 11:11

:bust_in_silhouette: Reply From: kidscancode

I highly recommend this tutorial to learn all about how VehicleBody works:

Hi, thanks for the answer. I did find the tutorial but I didn’t found it particularly useful: When the car is imported all the relevant parts are set up automatically but I try to understand how to set up a car myself. And there is really little available on that :frowning:

1izNoob | 2020-10-01 09:33

Thank-you so much for sharing this video, it helped a lot.

I had a feeling that it was the wheel settings that were not being set properly, and learning that the vertical starting transform position (ie. y-value) should be equal to the ‘rest_length’ of the wheel, because the center of the wheel actually represents the mounting point!, not the top of the spring!

On top of that, for a 750 kg vehicle, i set each tire max force to 10k, that seemed to work well. rest_length to 0.4 (and same for y-value of transform). I also put the ‘travel’ at half that (0.2) like he suggests in the video, and stuffness at 65. compressions at 1.135, and relaxation at 0.88. Whammo, it rides like a beauty!

I think the real issue is the documentation is inaccurate, or unhelpful and should be updated. This video makes things much clearer.

Ciao!

qaptoR | 2022-02-24 21:09

I tried your settings, but the car either flips when turning or - doesn’t turn nearly as much as desired (if I reduce the Friction Slip). What engine_force do you have - and what is your top speed and acceleration?

Gatada | 2022-09-12 14:15

:bust_in_silhouette: Reply From: Gatada

Wobble of wheel misaligned to axel (VehicleWheel3D node)

  1. The radius of the VehicleWheel3D node as shown in the 3D view sets the size of the wheel as used by the physics. So matching the radius with the wheel models prevents them from floating or being clipped by the ground (under ground).

  2. The VehicleWheel3D node creates the axel for the wheel model. So if the origin of wheel does not match the axel, the wheel model will spin off-centre (ref. animated gif).

  3. KidsCanCode already provided a very useful link. Her is another (skipping straight to the wheel part of the tutorial): https://youtu.be/Q33z_L6s6Go?t=492