I have a code to make a bullet animate across the screen whenever a key is pressed, but I can't seem to get it to collide with my enemy properly. Here's the code snippet.
Code: Select all
if(borka_coll.intersectsWithBox(zap_coll)){
borka->setMaterialTexture( 0, driver->getTexture("../../media/boxy.tga") );
}else{
borka->setMaterialTexture( 0, driver->getTexture("../../media/boxyred.tga") );
}
if ( receiver.Keys[ KEY_KEY_W ] && !bKeyWasPressed){
IAnimatedMesh* mesh = smgr->getMesh("../../media/bullet1.x");
IAnimatedMeshSceneNode* zap = smgr->addAnimatedMeshSceneNode( mesh );
zap->setMaterialFlag(video::EMF_LIGHTING, false);
zap->setMaterialTexture( 0, driver->getTexture("../../media/ProjectileBlue.tga") );
zap->setRotation(core::vector3df(0,270,0));
zap->setScale(core::vector3df(.5,.5,.5));
scene::ISceneNodeAnimator* anim2 = 0;
scene::ISceneNodeAnimator* dele2 = 0;
// set flight line
anim2 = smgr->createFlyStraightAnimator(core::vector3df(boxy_x,boxy_y,boxy_z),core::vector3df(boxy_x - 40,boxy_y,boxy_z), 3000,false);
dele2 = smgr->createDeleteAnimator(30000);
zap->addAnimator(anim2);
zap->addAnimator(dele2);
anim2->drop();
}
Currently everything works but the actual collision detection.
Edit: I actually just thought of a workaround that may work, but I'd still like to know if a more direct solution exists.