How to replicate the behavior of the vehicle wrapper?

Hello! My question is:

  • How to replicate the behavior of the vehicle wrapper (KX_VehicleWrapper)?

It’s just for the sake of research and learning, I know the vehicle wrapper was created to simplify the task of creating vehicle physics, and creating it from scratch again is (somewhat) useless. I would like to understand how it works ‘behind the scenes’.

What I probably know is just the wheels are ‘aesthetical’, the ‘real’ wheels are rays that check the distance from the chassis to the ground. From this point, what happens? We use chassis.applyImpulse in the position of the corresponding wheel? If not, what must be done to keep the chassis ‘floating’ on the ground?

Thanks in advance. :wink:

Well, now THAT’S complicated. I don’t really know what is happening “behind the scenes”, but a good idea might be to turn on Physics Visualization. That might help some. For example it shows the wheel centre, and probably casts some sort of ray as you say, in the direction that you specified (normally [0, 0, -1]).
But anyway, good luck learning it! It is always nice to learn more…

Is it a bpy or bge method?

A bge class to manage vehicle physics. See more at: http://www.tutorialsforblender3d.com/Game_Engine/Vehicle/Vehicle_2.html

Oooh I second this notion! I’ve always wondered how it worked under the hood : P

Up!

I’m still looking for this information…

ok, I think for each wheel it raycasts down, if the ray hits it places the wheel at that location+the wheel radius.

it also divides the weight of the vehcile amoung the tires on the ground,
and uses apply impulse (weight/tires) at the wheel point.

In my own experiments

if wheelhub.local.x > 1 and touching, cancel some y rotation if its (positive?)

if wheelhub.local.y > 1 and touching cancle x rot if its (positive or negative it’s been a minute)

it’s been a while.

this is how I made my vehicle wrapper