Advertisement

PhysX IsGrounded not accurate

Started by June 02, 2024 11:11 AM
2 comments, last by Alundra 6 months, 3 weeks 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!

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 ?

Advertisement

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!

This topic is closed to new replies.

Advertisement