Letting two btKinematicCharacterControllers collide

LtJax
Posts: 8
Joined: Thu Sep 18, 2008 2:37 pm

Letting two btKinematicCharacterControllers collide

Post by LtJax »

Hello,

I've set up a small application where two people can run around with a btKinematicCharacterController on a flat plane. I mostly followed the CharacterDemo while setting this up. Everything seems to work just fine, except that the two characters can walk right thru each other.
From what I gathered so far, this is actually to be expected, as I have to implement collision response myself for character controllers. But how would I do that? Any pointers are welcome.

Thanks in advance,
Marius

PS.: I'm using bullet version 2.74
pico
Posts: 229
Joined: Sun Sep 30, 2007 7:58 am

Re: Letting two btKinematicCharacterControllers collide

Post by pico »

Hi,

i would suggest to modify/make another recoverFromPenetration() routine in the character contoller. When you go through the manifolds check if both bodies are characters. If yes, do something like this:

m_currentPosition += pt.m_normalWorldOnB * directionSign * pt.getDistance() * btScalar(0.2);
his_currentPosition += pt.m_normalWorldOnB * -1.*directionSign * pt.getDistance() * btScalar(0.2);//the other body

This would seperate both characters. This may be not what you actually want. Maybe you want to consider the actual move direction of both actors instead. Or you want just to stop them. There are many ways, it depends mainly on your type of game.

Dont forget to set the character filtergroup when adding your objects.
I would recommend not to use that filtergroup in the strafing/step callbacks.
LtJax
Posts: 8
Joined: Thu Sep 18, 2008 2:37 pm

Re: Letting two btKinematicCharacterControllers collide

Post by LtJax »

Oh thanx! Actually, when I was investigating the recoverFromPenetration routine, I thought that it should actually do pretty much what you suggested already. However, I was never getting collisions between the two characters - so I figured it must have been filtered out somewhere else. And indeed I was just missing the CharacterFilter when setting the collision mask.
Anyways, thanks a lot for pushing me in the right direction.