🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

PhysX IsGrounded not accurate

Started by
2 comments, last by Alundra 2 weeks, 4 days ago

Hi everybody,
I'm using the flag output of PhysX Character Controller Move:

const physx::PxControllerCollisionFlags flags = m_controller->move(physx::PxVec3(dist.m_x, dist.m_y, dist.m_z), 0.0f, elapsed, controllerFilters);
m_isGrounded = flags.isSet(physx::PxControllerCollisionFlag::eCOLLISION_DOWN);

Unfortunately, that looks to not be accurate enough.
The issue is since it's not accurate I get my jump action failing sometimes.
Is there any better way or something to improve it?
Thank you for the help!

Advertisement

I'm using v4.1.0 and came across a similar issue with vehicles physx::PxVehicleIsInAir no reporting the correct result. One workaround( still unimplemented) was to just check to contacts count reported for each wheel, if all wheels report no contact(s) then the vehicle is airborne and vice verse. I haven't touched the Character Controller API in while, but if you have access to the contact report for the controller, you could use that as an additional check, granted it won't tell you which direction the contact came from.
Taking a step back, when you say

Alundra said:
m_isGrounded = flags.isSet(physx::PxControllerCollisionFlag::eCOLLISION_DOWN);

do you mean its reporting true when the controller is clearing not in contact with any geometry in the PxScene ?

I modified how I'm doing, applying the gravity all the time, and it is working better now. Thanks for the info about vehicle can be surely a lot useful at one point!

Advertisement