# Physx gravity not working as expected

We have been facing a strange issue with physx vehicles. The game behaves correctly in almost every situation: jumps, impacts, etc.

Gravity is applied correctly downward.

But when the vehicle is put upside down in a track, in a loop or twist, somehow it's stuck to the track as if SpiderCar was playing.

Find a video of it here. And an image below:

We are using PxVehicleUpdate::updateDrive4W as coming in the framework version 3.2.2 So the call is just

void VehicleManager::updateVehicle(const PxF32 timestep,
const PxVec3& gravity,PxVehicleDrivableSurfaceToTireFrictionPairs * mSurfaceTirePairs)
{
}


Gravity is a vector (0.0,-9.8,0) being Y the vertical coordinates. Inside it calls updateDrive4W for all the vehicles, which is about 400 lines

• I'm guessing if you were to flip the car upside-down it would float up into the air? It seems as though you're applying the gravity to the cars local down, instead of the world down. Nice improvements on the question. – MichaelHouse Jun 5 '13 at 14:55
• Actually, when the car is in air or somehow it breaks connection to the track, it works fine. For example, if you collide with the borders or other car with enough force the "spell" breaks and it falls down. So gravity is applied globally. – Ender Jun 5 '13 at 15:15
• You don't have any other forces being applied to the vehicle? Something to keep it on the road in the first place? Can you post a snippet of code showing how you've created the car and how you're updating it. Smallest amount of code possible. – MichaelHouse Jun 5 '13 at 15:19
• No extra forces added, we tried to investigate if physx applies itself a force that, consistently with forces in real world, would apply a force towards the track incremented exponentially by the velocity. But we found nothing – Ender Jun 5 '13 at 15:38
• Actually, I'm betting that PxVehicleDrivableSurfaceToTireFrictionPairs is adding forces to keep the car on the road. You may want to look into the documentation for that. – MichaelHouse Jun 5 '13 at 15:40