[SOLVED] b3 VehicleWheel and getGroundObject

Hello,

I am trying to determine if all wheels of vehicle is off the ground (TerrainQuad). I tried to use getGroundObject but in beta3 that does not work so good (always returns null). In the source repo (r9060) it is guaranteed to return null :slight_smile:



What would be the recommended way to query a wheel if it is in contact with anything?



Cheers,

JM

getGroundObject doesn’t work in bullet at all, not even in the native version. maybe you can check the rest length, it should always be below max if the wheel touches the ground.

1 Like

In b3 it seems to works with checking if the ground object in the raycastInfo is not null.



[java]VehicleWheel wheel = physicsControl.getWheel(n);

final WheelInfo wheelInfo = wheel.getWheelInfo();

final RaycastInfo rayCastInfo = wheelInfo.raycastInfo;[/java]



[java]boolean contact = (rayCastInfo.groundObject != null);[/java]



But the rest length also works, as you suggested.



[java]boolean contact = (rayCastInfo.suspensionLength < suspensionRestLength) ;[/java]



I’ll stick to checking the rest length. Thanks for the tip.

Hm, you should not use the wheelInfo directly as it cannot be accessed in native bullet (which is used on android, optionally on desktop and in the future probably always). I guess I should make that ray cast stuff accessible via the object as well…

I see. Yeah, it’d be nice to be able to get some info out, if it is available that is :slight_smile:

One way I tried was to look for the wheel world location and compare with the ray cast collision but I couldn’t find the wheel world coordinates. Maybe I simply missed it.

Another way might be to register collision listeners on the wheels even if they aren’t really rigid bodies. I guess it would require some wrapper code to “hide” the ray cast nature. Don’t know if that is better or only trouble for no gain.