I was implementing CharacterControllers into my engine and came across an odd problem:
My Controllers wont collide with static geometry and even though I set a callback onShapeHit never gets called. When running my sample with PVD attached it looks like all the shapes are there but even when they start to overlap onShapeHit isn’t called.
Furthermore the character tosses dynamic actors around.
So to me it seems the character controller behaves strictly like a dynamic kinematic actor (which it is under the hood).
I have the eSCENE_QUERY_SHAPE and eSIMULATION_SHAPE set for all shapes and use the move() method of the character controller, which i thought would call onShapeHit.
This is my code for creating the CharacterController, I couldn’t spot any differences to the sample code shipped with the PhysX sdk.
PxControllerFilters filter = PxControllerFilters( );
PxU32 collisionFlags = m_pController->move( CBVECTOR3D_2_PXVEC3( direction ), 0.001f, m_dt, filter );
if ( PxControllerFlag::eCOLLISION_DOWN == collisionFlags )
{
// do something
}
I used PVD to inspect my scene and the sample scene. There were no differences in the actors and shapes attributes.
Is there any flag I could habe possibly disabled that breaks the functionality of move()? I can’t shake the feeling that is something really minor I am missing here.
Thanks in advance for any help
Edit: attached a PVD scene with my scene. It has a Static and a Dynamic Actor and the Character Controller. CharacterCtrl.zip (325 KB)
please write which version of PhysX do you use.
I guess PhysX 3.2.x
One other thing: I think its not recommended to inheriate your “player” class the PxSimulationEventCallback - use a new class for it.
[If you have many “players” with different behaviour as example, its easier to modify it]
I didnt saw the PVD, but are your dynamic objects collideds with the trimesh?
Did you use a custom filtershader?
(Is m_dt a small value - (how fast are your player moving [gravity])
(Maybe your Trimesh face order is wrong)
Maybe the PhysXGuide or the Samples / Snipptes could help you.
Especially the Sample: Bridges / Character.
Please look inside it!
I don’t think the filter is the problem. I looked into the Northpole sample, which has a character walking on a heightfield and colliding with a static triangle mesh. The filter in this sample is not called when the character collides with statics. Only collisions with dynamics trigger the filter. Statics trigger onShapeHit (although not in my case).
Sorry I dont use PhysX 3.2x anymore, I´m using PhysX 3.3.
If I remember corretly, you have to set the ControllerCallback from the controllerManager pointer.
This changed in PhysX 3.3 - to a better system, each controller have to set a individual callback.
This is what im doing in 3.3:
okay updating to 3.3 seems like a good idea :)
I did build a debug version of the PhysX3CharacterKinematicCHECKED_x86.dll and when going through the whole move method it seems like my shapes don’t get enumerated by the scenequery.
I saw that the scene query flag for statics is set and all my shapes have eSCENE_QUERY_SHAPE set to true.
Okay now I am sure what the problem is. For some reason my shapes won’t show up in scene queries.
Is there any other setting besides eSCENE_QUERY_SHAPE (which is turned on) the needs to be enabled for scene queries to work?
finally I found the root of my problem.
Its the client ID. I created my scene with a client ID and set all my actors to use this ID.
But it looks like this breaks scene queries, I guess its a bug?
When I change my ID back to PX_DEFAULT_CLIENT everything works fine.
mFilterData receives the same filter data from shape’s controller. But in this case, I don’t use filter callback for test and anyway there is not collision.
My filterData is:
word0 = groupReportCollision;
word1 = groupsMaskReportCollision; //with which groups will report collision
word2 = layerGroup