I want to get contact point of wall.

I want to get contact point of wall.

Hi !!!I use ofhkpCharacterRigidBody for collision.And, I found contactPoint byhkpRigidBody::getLinkedCollidable().I would like to classify contactPoint into wall-contactPoint and terrain-ContactPoint.Thanks~~~

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

If I understand correctly, you want to determine if your character collides with a wall or terrain object and get the contact point?

I would recommend taking a look at the ControlCharacterRbDemo in Demo/Demos/Physics/UseCase/CharacterControl/CharacterRigidBody/ControlCharacterRb for an example of using the LinkedCollidable to process contacts. See the stepDemo() function where it detects the character near a ladder.
Just so you know, you could use a contact listener instead of processing CollisionEntries in the LinkedCollidable. To do this you need to add a contact listener to your character's rigid body. Any of the demos in Demo/Demos/Physics/Api/Collide/ContactPointCallbacks are a good reference for this. I recommend the DeterministicCallbacksDemo.

For distinguishing walls vs terrain you have a few options depending on what you consider a wall or terrain.
Off the top of my head I see two potential choices:
1) Use the contact normal. If it's not very 'up' (dot it with a global "up vector") then consider it a wall. If you use the contact listener you can get the contact normal in the contactPointCallback with: event.m_contactPoint->getNormal(). If you use the collision entries via linkedCollidable see how 'ladderNorm' is accessed in ControlCharacterRbDemo.
2) Flag all your objects as as wall or terrain. You can use rigidbody properties to flag them. To do this use addProperty() on each body when you create it to flag it as wall or terrain. Then when you detect a collision look up the property on the body you collide with. ControlCharacterRbDemo is a good example of doing exactly this (where it detects the ladder). If you want to use a contact listener then you can get the bode you collide with via:

hkpRigidBody const* collidingBody = event.getBody( 1 - event.m_source );

Hope this helps,
Tyler

Login to leave a comment.