PhysX
PhysX copied to clipboard
"Steered wheel" joint from the documentation doesn't work when powered
I've noticed a very strange issue trying to use the D6 joint to make a "steered wheel" in Unreal Engine. According to the documentation, this is supposed to be supported:
https://gameworksdocs.nvidia.com/PhysX/4.1/documentation/physxguide/Manual/Joints.html#d6-joint
In vehicle applications, these joints can be used as 'steered wheel' joints in which the child actor is the wheel, free to rotate about its twist axis, while the free swing axis in the parent acts as the steering axis.
However, it seems that when you actually try to do that, it goes crazy when you then try to use the swing drive to steer the wheel.
Here is one such joint set up in Unreal Engine:
This is supposed to make a steered wheel that slowly spins without steering. However, the result is this, flapping about without any input at runtime:
https://user-images.githubusercontent.com/6764788/177058443-c7cef833-50e9-4655-ab73-dafb45b74530.mp4
In the end I tracked it down to the swing drive (accidentally?) being computed with the pose of the child actor rather than the parent one. To me this only makes sense for the twist drive, but not the swing one. After making this change: https://github.com/Zeblote/PhysX/commit/f3d4f0cc9d3205dee0db9122f71fcadc1490aab3 I am able to control my wheel as intended, using the swing and twist drives separately to steer and drive.
https://user-images.githubusercontent.com/6764788/177058504-e87feabc-639d-4019-b005-9f0b44955df1.mp4
I don't have a good understanding of that code, it would be nice for someone to clarify what the intended behavior is and whether this was a bug.
Thanks for reporting. I'm going through the code and I think you're right about this being an error. The swing axes should be in bodyA frame while the twist axis should be in body B frame.