Character controller interaction with a body

mamairaja

13-03-2011 11:49:20

I am using following code to make a body

Critter::BodyDescription bodyDesc;
bodyDesc.mWakeUpCounter = 1E8;
bodyDesc.mMass = 600;

body = critter->createBody(shapedesc, NxOgre::Vec3(0, 100, 0), "JBC.mesh", bodyDesc);
body ->setGroup(ControllerShapeGroups::CSGROUPS_OBJECT);


But this body just throw away when my character controller hits it. It's a quite larger object when compare to my character. So I don't want to throw it away when Character hits it. Instead I just want stop the character when hit.

Could you please tell me how to stop this throwing away?

betajaen

13-03-2011 12:12:38

Have a look at Callbacks. Essentially you have to apply the force yourself. Normally without the Callback the CharacterController is essentially clipping the Body causing the Body to move, if you consider the CharacterController to have infinite mass you'll understand why it moves around when it shouldn't do. The same is true of KinematicActor/Bodies.

mamairaja

13-03-2011 18:25:46

Thank you for the reply.

if you consider the CharacterController to have infinite mass
So if the character controller has infine mass it is the reason to throw away the object right?
mass * velocity = mass * velocity

One question to ask.

In physx does the callback function calls before it apply the effect on other body?

Thanks

betajaen

13-03-2011 18:53:32

It doesn't really apply any force to the Body. None at all, the KinematicActor/CharacterController, more or less teleports partially inside the Body. The Body then notices this and tries to get away.

The Callback is to move the Body before it happens.

mamairaja

13-04-2011 18:59:49

Hi again,

I tried to implement callbacks, and didn't success to find whether character controller hits with a particular body.

I set the group of the body as

dChair->getBody()->setGroup(ControllerShapeGroups::CSGROUPS_OBJECT);

And onShapeHit function
NxOgre::Enums::CharacterControllerAction PlayerCharacterCCImp::onShapeHit(const NxOgre::CharacterControllerHit& hit)
{
if(hit.mHitShape)
{
DebugMessage("Hit with a shape\n"); // always prints, hit.mHitShape->getGroup() always has value 1
if(hit.mHitShape->getGroup() == ControllerShapeGroups::CSGROUPS_OBJECT)
{
DebugMessage("Hit\n"); // never prints
}
}
return NxOgre::Enums::CharacterControllerAction::CharacterControllerAction_None;
}


It always prints "Hit with a shape" and hit.mHitShape->getGroup() value always has the value 1,
but never prints "Hit".

kindly tell me what else I can try.

~mamairaja