Callback for collision detection Body & CharacterController

mistigrii33

07-11-2011 20:41:06

Hi,

I'm trying to set a CallBack when something (it will only be my AnimatedCharacter) hit a Body.


Critter::Body* bonus1 = mRenderSystem->createBody(box_desc, NxOgre::Vec3(-100, 30, -100), "bonusMesh.mesh", bodyDescription);

MyCallBack* myCallBack = new MyCallBack();
bonus1->setContactCallback(myCallBack);


myCallBack :

class MyCallBack : public NxOgre::Callback
{
public:
MyCallBack(void);
~MyCallBack(void);
void onContact(const NxOgre::ContactPair& pair);
};


When my AnimatedCharacter hit the box, the onContact function isn't called. What am i doing wrong ?

I can't do something like mScene->setActorFlags(bonus1, myAnimatedCharacter, NxOgre::Enums::ContactPairFlags_All);
because wrong parameters type..

Thanks!

mistigrii33

08-11-2011 15:11:41

I solved my problem by changing the CritterCharacterBase.h file from

class CritterPublicClass CharacterBase : protected NxOgre::CharacterController, protected NxOgre::TimeListener, protected NxOgre::Callback
to
class CritterPublicClass CharacterBase : public NxOgre::CharacterController, protected NxOgre::TimeListener, public NxOgre::Callback

and recompiling Critter. The problem was that i couldn't cast the CharacterController to RigidBody because the cast wasn't accessible.

If there's a better solution than mine, thanks to advice me.