Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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:

share|improve this question
What coordinate system is the l_v3Position in? Where are you getting that value from? Where is the origin in the character model in the source artwork? The answer to one of these questions will probably solve your problem. –  Tom Whittock Jan 27 '12 at 10:45
@TomWhittock l_v3Position is in world coordinates and is (0, 0.93, 0). The origin of the character model is the pelvis, but he's being rendered with a negative offset so that his feet touch the ground. My problem is that the capsule is not touching the ground. If everything was working correctly I'd expect the model to be sunk up to his knees in the floor! –  Jannie Jan 27 '12 at 11:44
I don't know PhysX, but: Is it possible that the capsule is actually touching the ground, but the ground's collision volume is above where the ground is being rendered? That would account for the described effects. What are the results if your character stands on one of the "correctly wrapped" bodies? –  Kevin Reid Feb 1 '12 at 14:41
The capsule behaves exactly the same standing on any collision objects in the scene. I'll edit in a screenshot of some correct stacking behavior next to the capsule, for comparison. –  Jannie Feb 2 '12 at 5:49
add comment

migrated from stackoverflow.com Jan 31 '12 at 17:36

This question came from our site for professional and enthusiast programmers.

1 Answer

up vote 0 down vote accepted

The first link has the answer to that problem http://forum-archive.developer.nvidia.com/index.php?showtopic=6409

OK, well I figured out this "magic" number ... the capsule will always be [Radius + (Height/2) + contactOffset ] off the ground. Hope this helps someone.

contactOffset is 0.1 by default and if you change it to 0.01 it should be really close to the ground

share|improve this answer
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.