Closed dacete closed 1 year ago
Hmm I tried other diff modes with my vehicle demo and they seem to work fine, so my guess is you are doing something wrong.
I do my vehicle setup here: Vehicle.kt, diff mode is set in line 183. It's kotlin not Java but maybe it helps.
Thanks for checking, Yes I am following your kotlin vehicle already, I guess I'll try again to find what I'm doing differently.
I found and fixed my problem, here it is for others who might try to do something similar to me. At first, before I even added the vehicle part, I did rigidbody.setMass() to apply 1600kg to my car, but this caused it to glitch around badly, falling though the ground etc. So I just used a mass of 1 instead, which worked, because I thought mass is relative and I could just tweak the vehicle forces to make it behave the same. So somehow this didn't work well for physX internally, because the wheel's MOI was too big for the rear wheels to even turn the front wheels, and if set lower the front wheels would just slide. I'm guessing there's either some more parameters I didn't adjust for this 1kg car, or physX has some internal ones I can't change. Either way what I did to fix it was to use PxRigidBodyExt.setMassAndUpdateInertia(rigidbody,1600), after applying the shapes to the car, and now it works great.
Ah I think the inertia was your problem. As a tip: You should always set an inertia appropriate to mass (e.g. by using PxRigidBodyExt.setMassAndUpdateInertia(body, mass)
you already mentioned). Without correct inertia, bodies will glitch heavily (not only vehicles, but all kinds of bodies).
Well my car seems to behave normally now, except the wheel friction which seems like it's on ice. I tried adjusting so many values to high amounts and nothing seems to work. I changed the surface material friction, the friction pair setTypePairFriction multiplier, setMLatStiffX and Y for the car tires, and they don't seem to make any change. I'm at a loss for where to look next.
When setting up a car, eDIFF_TYPE_LS_4WD works fine but any other, such as eDIFF_TYPE_LS_REARWD, seems to spin the rear wheels but the front ones are "braking" and wont rotate, even though I'm not applying any braking or handbrake input. This makes the car unable to move. I don't know if this is something I'm doing wrong, or a bug. Any clues? Thanks.