PhysX Capsule Character Controller floating above ground

Posted by Jannie on Game Development See other posts from Game Development or by Jannie
Published on 2012-01-27T10:06:21Z Indexed on 2012/06/27 9:24 UTC
Read the original article Hit count: 224

Filed under:
|

I am using PhysX Version 3.0.2 in the simulation package I'm working on, and I've encountered some bizarre behavior with the capsule character controller.

When I set the controller's height and radius to the appropriate values (r = 0.25, h = 1.86)it behaves correctly (moving along the ground, colliding with other objects, and so on) except that the capsule itself is floating above the ground. The actor will then bump his head when trying to get through a door, since the capsule is the correct height but also floating above the ground.

This image should illustrate what I'm going on about:

The capsule is clearly much too small!

One can clearly see that the rest of the scene has their collision bodies wrapped correctly, it's just the capsule that's going wrong!

The stop-gap I've implemented is creating a smaller capsule and giving it an offset, but I need to implement ray-picking for the controller next so the capsule has to surround the character model properly.

Here's my character creation code (with height = 1.86f and radius = 0.25f):

NxController* D3DPhysXManager::CreateCharacterController( std::string l_stdsControllerName, float l_fHeight, float l_fRadius, D3DXVECTOR3 l_v3Position )
{
    NxCapsuleControllerDesc l_CapsuleControllerDescription;

    l_CapsuleControllerDescription.height = l_fHeight;
    l_CapsuleControllerDescription.radius = l_fRadius;
    l_CapsuleControllerDescription.position.set( l_v3Position.x, l_v3Position.y, l_v3Position.z );

    l_CapsuleControllerDescription.callback = &this->m_ControllerHitReport;

    NxController* l_pController = this->m_pControllerManager->createController( this->m_pScene, l_CapsuleControllerDescription );
    this->m_pControllerMap.insert( l_ControllerValuePair( l_stdsControllerName, l_pController ) );
    return l_pController;
}

Any help at all would be appreciated, I just can't figure this one out!

P.S. I've found a couple of (rather old) threads describing the same issue, but it seems they couldn't find a solution either. Here are the links:

© Game Development or respective owner

Related posts about c++

Related posts about physx