Problem with NxUserControllerHitReport

pierewiet

27-04-2010 14:40:41

Hello. I have a question concerning some problem in NxUserControllerHitReport and I thought I'd try my chances here.

So basically, we have a charactercontroller set up and there are some dynamic actors in the scene. At the moment we hit some dynamic actor, we wish to delete it from the scene. In short, the code looks like this:


class ControllerReport : public NxUserControllerHitReport
{
public:
virtual NxControllerAction onShapeHit(const NxControllerShapeHit& hit)
{
NxActor* hitActor = &(hit.shape->getActor());
NxActor* ctrlActor = hit.controller->getActor();

if ((hitActor->getGroup() == COLLISIONGROUP_BANANAS) //if the dynamic actor is from the right group
&& (hitActor->getLinearVelocity() == NxVec3(0, 0, 0)) //if it's lying still
&& (((Character*) ctrlActor->userData) == CharacterManager::getSingletonPtr()->getMainCharacter())) // if our main character is touching it
{
int charID, bananaID;
sscanf(hit.shape->getActor().getName(),"banana_%d_%d", &charID, &bananaID);

BodyManager::getSingletonPtr()->removeBody(hit.shape->getActor().getName());
}

return NX_ACTION_NONE;
}
};


The error occurs at
NxActor* hitActor = &(hit.shape->getActor());

Somehow the NxControllerShapeHit object seems to be completely wrong. Sometimes the debugger is saying the hit object has address 0, 1, 7 or whatever. Wrong things at least. This ONLY happens when we hit two or more dynamic actors close to eachother, or at the same time.

Any ideas? :|