[SOLVED] Question about wheel offset during higher speed for vehicle sample

[UPDATE 2: Forgot to mention, the problem when this occur is armory3d 0.4alpha with the vehicle from the same release]


I am trying to extend the existing vehicle demo to a more racing car like feel.

But got a strange behavior (this behavior seem to be more visible once change the vehicle shape from default sphere to a custom shape):

On higher speed moving, the vehicle wheels will be moving behind the chassis

I try to tweak the suspension (from 20 to 200), damping (from low value 0.3 to higher value) and other settings, but seem do not make too much differences compare to the original demo

Please see the image below, the vehicle is moving toward right, but the wheels are lagging behind (the higher speed the vehicle, the greater that lag). This problem is not only for speeding forward, but for backward also, as long as speed is building up, the wheel will lag behind the chassis.

According to another StackOverflow thread

The solution mention there is a motion state :

The issue seems to be that the MotionState's callbacks are being called on a different thread to the render function. In Xoppa's sample app (here, for anybody else reading along), the wheel transforms are being updated in the render thread. The fix was to do the wheel transform in the MotionState's callback as well

But I am kind of fail to find how to locate this MotionState Callback in Armory3D Haxe code. Is this a supported feature or it in current Armory, the MotionState will not be supported. If there is other way to resolve the problem, it will also be great.


Compare to when the vehicle is moving at stop (sorry did two post to be able to post two images)

After some more debugging and play around different values. Found a working approach (not sure if it is the right approach, but it seem work)

Tires now stick to chassis even at high speed

The key seem to be disable the interpolatedTransform as suggest in the last post at here


So in the vehicle demo, I need to update

			// Synchronize the wheels with the chassis worldtransform
			vehicle.updateWheelTransform(i, true);


			// Synchronize the wheels with the chassis worldtransform
                        // Update the second parameter to false in order for the 
                        // wheel to stay with chasis
			vehicle.updateWheelTransform(i, false);

In theory, the interpolatedTransform should sync up the state more accurate from reading of the bullet physic code.


 void    btRaycastVehicle::updateWheelTransformsWS(btWheelInfo& wheel , bool interpolatedTransform)
         wheel.m_raycastInfo.m_isInContact = false;
         btTransform chassisTrans = getChassisWorldTransform();
         if (interpolatedTransform && (getRigidBody()->getMotionState()))
         wheel.m_raycastInfo.m_hardPointWS = chassisTrans( wheel.m_chassisConnectionPointCS );
           wheel.m_raycastInfo.m_wheelDirectionWS = chassisTrans.getBasis() *  wheel.m_wheelDirectionCS ;
        wheel.m_raycastInfo.m_wheelAxleWS = chassisTrans.getBasis() * wheel.m_wheelAxleCS;

but may because my computer is slow so the motionstate (or physic thread) thread may be still in process while get the wheel transform, so the chassis are already updated to different location in another thread?

But now it seem to work so will close the thread. But if others have better suggestion, please feel free to suggest.