I am quite new to Irrlicht and i am trying to make a simple game of a mesh with a hole in it moving towards the player. It is my intention to let the player pass through the hole.
Now i needed somekind of detection of collision.
However as i attached the triangle selector to the moving node, which has been animated by a flystraight animator. With the player currently consisting of a few sphere nodes attached to a collision response animator that should reacts to the moving mesh. Due to the shape of the moving mesh i cannot attach the triangle selector to the player and use the collision response animator on the moving mesh.
The collision didn't seem to happen so i tested and simplified it a bit and to see what happened, i used a fps camera with attached collision response animator to fly through the scene and check for collisions.
It seems as long as the Mesh wass moving, the collision detection didn't happen. As soon as the moving mesh is stationary it works.
Anyone have any idea how i can solve this problem and have collision detection working when the mesh with triangle selector is still moving?
Some of my code (which i think are important to the problem i face).
Code: Select all
//The moving mesh:
blck = smgr->getMesh("media/block01.x");
block = smgr->addOctTreeSceneNode(blck,0,-1,256,false);
........
irr::scene::ISceneNodeAnimator *anim;
//create movement animation
anim = smgr->createFlyStraightAnimator(block->getPosition(), irr::core::vector3df(0,20.0,-10.0), irr::u32(5000),false);
block->addAnimator(anim);
anim->drop();
//create collision selector
selector2 = smgr->createOctTreeTriangleSelector(blck->getMesh(0),block,128);
block->setTriangleSelector(selector2);
selector2->drop();
//The player
for(int i=0; i < 5; i++){
node[i] = smgr->addSphereSceneNode(1,16,0,-1,irr::core::vector3df(posAvatar[i][0],
posAvatar[i][1],posAvatar[i][2]));
//create the collision response animator
collision[i] = smgr->createCollisionResponseAnimator(selector2,node[i],
irr::core::vector3df(2.0,2.0,2.0), //radius of collission detection
irr::core::vector3df(0,0,0), //gravity of collision
irr::core::vector3df(0,0,0)); //elipsoid translation
//attach the collision response animator to the node
node[i]->addAnimator(collision[i]);
collision[i]->drop();
}