Hello!
I'm working on a little project with Irrlicht 1.7.2 and IrrPhysx. I already have a charakter, which I can move through the Q3-Map. With IrrPhysx everything works fine! But I have a question about Collision Detection:
How can I get a Pointer to an object, which collides with my character So for example: My character is walking through the Map and suddenly it's colliding with a cube. Now I want that the cube is invisible... how can I do that?
PS: Sorry for my bad english, I'm from Germany
IrrPhysx Collision Detection
Re: IrrPhysx Collision Detection
You can check it in ContactReportExample for PhysX.
Code: Select all
void contactCallback(IPhysxObject* objectA, IPhysxObject* objectB) {
if (objectA->getType() == EOT_SPHERE && objectB->getType() == EOT_SPHERE) {
core::vector3df pos;
// Find the physx objects in our array of physx and node pairs and remove them
for (u32 i = 0 ; i < objects.size() ; ++i)
if (objects[i]->PhysxObject == objectA) {
// Add a visual effect of the removal
objects[i]->PhysxObject->getPosition(pos);
addPlasmaBallEffect(pos);
// Remove the physical and visual representations
physxManager->removePhysxObject(objects[i]->PhysxObject);
objects[i]->SceneNode->remove();
delete objects[i];
objects.erase(i);
--i; // erase(i) just shuffled everything back 1 so we need to update i to reflect this
} else if (objects[i]->PhysxObject == objectB) {
// Add a visual effect of the removal
objects[i]->PhysxObject->getPosition(pos);
addPlasmaBallEffect(pos);
// Remove the physical and visual representations
physxManager->removePhysxObject(objects[i]->PhysxObject);
objects[i]->SceneNode->remove();
delete objects[i];
objects.erase(i);
--i; // erase(i) just shuffled everything back 1 so we need to update i to reflect this
}
}
}
//And in main while you put this code:
// Set our contact callback function so the physx manager can inform us of contacts between objects
physxManager->setContactCallback(&contactCallback);