How to handle wheel on wheel interaction with PhysX Vehicles?

I’ve been trying to fix a problem that’s plaguing the Unreal Engine 4 community when it comes to using vehicles. I believe this problem stems from how wheel on wheel contact is being handled (or not handled) in the PhysX vehicle class. The problem is that any time a wheel comes into contact with another wheel, the vehicle get launched into the air with an insane amount of force. As you can guess the makes any sort of open wheeled vehicle interaction impossible. While attempting to fix the issue I ran into a different problem, when I put in some code to handle the scenario when the PXRigidBody is Kinematic, it crashes the system on the physX side with a NULL memory reference. This is odd considering it has all the information about the bone stored in memory, as is shown when I’m running the debugger. But when attempting to handle the circumstance it deletes the info in the reference and crashes trying to read it. I originally thought it was a miscalculation due to the Unreal Implementation, but that doesn’t seem to be the case. Any help would be greatly appreciated, as trying to fully understand all that’s going on in PhysX feels a little beyond me at the moment, and I would like to see our game progress.

I don’t really know the details of UE4 vehicles but I have a suspicion that I know what is happening here.

PhysX vehicles are basically raycast vehicles with collision volumes for wheels and chassis and any other body parts. This is a mixed representation because raycasts are used to decide what the wheels drive on in the driving model, while the collision volumes decide what they collide with in the rigid body update. It is important not to mix the two because that will lead to poor handling and all sorts of weirdness. I’ll explain this statement a bit more. Let’s imagine that a wheel is resting on the ground. In this imaginary scenario the suspension raycasts are hitting the ground and the wheel’s collision volume is hitting the ground too. This will lead to poor vehicle handling because the wheel is supported by the rigid body contact rather than by the suspension. What we really want is for drivable surfaces to interact only with the suspension raycasts, while non-drivable surfaces interact only through rigid body contact. This is achieved by setting filter data to callbacks called by the raycast code and by the rigid body contact code. Potential hit shapes can be discarded in these callbacks.

My suspicion is that wheels are treated as drivable surfaces in UE4. Accordingly, wheel-wheel collision will also be disabled. This combination and the limited sampling from raycasts means that if one wheel A rolls towards wheel B it will drive right through it until either the centre of wheel A is inside the wheel B or the centre of wheel B is inside wheel A. When this happens wheel A thinks it has to resolve a very deep penetration with wheel B and tries to lift itself up to resolve the hit reported by the raycast. This leads to an enormous suspension force and the car is likely to flip upwards. If wheel B simultaneously thinks it has to resolve a contact with wheel A then you have the situation of both wheels being pushed upwards and likely continually pushing each other upwards until they part. I suspect this is what you are experiencing.

The solution is to first modify the simulation filter data applied to the wheels so that wheel-wheel rigid body contact is enabled. With this change wheels will bump off each other. With luck that alone will be enough to stop wheels trying to drive on other wheels. I can’t think of any reason for a wheel to drive on another wheel so you probably want to modify the scene query filter data too. This second part is less crucial and really depends on what you want to achieve and what sort of scenarios you have in your game.

I’m not sure how to modify the simulation filter data of a wheel in UE4. There are some collision options for regular dynamic actors in the UE4 editor. Perhaps those apply but I think there should be something in the vehicle blueprint for this. If there isn’t then it would be a great addition.



Wow, that makes perfect sense. I appreciate the quick response. I’ll see if I can figure where and how to change the simulation filter data to enable wheel on wheel collision. Thanks for the help, and I’ll let you know if I get it fixed.