This gets called by the draw loop.
Code: Select all
void checkCollision()
{
if(Bullet)
{
if(Character)
{
if (characterIsAlive)
{
if(Character->getTransformedBoundingBox().intersectsWithBox(Bullet->getTransformedBoundingBox()))
{
Character->setVisible(false);
characterIsAlive = false;
}
}
}
}
}
Code: Select all
void shoot(core::vector3df position, core::vector3df rotation, core::vector3df endPosition)
{
if(intCount >0)
{
BulletMesh = smgr->getMesh("media/Weapons/BFG/bullet/bullet.3ds");
Bullet = smgr->addAnimatedMeshSceneNode(BulletMesh);
core::vector3df addRotation;
addRotation = core::vector3df(90,0,0);
core::vector3df end = (endPosition - position);
end.normalize();
end = position + (end * camera->getFarValue());
Bullet ->setScale(core::vector3df(20,20,20));
Bullet ->setPosition(position);
Bullet ->setRotation(rotation + addRotation);
Bullet->setMaterialFlag(video::EMF_LIGHTING, false);
f32 length = (f32)(end - position).getLength();
const f32 speed = 10.0f;
u32 time = (u32)(length / speed);
anim = smgr->createFlyStraightAnimator(position, end, time);
Bullet->addAnimator(anim);
anim->drop();
anim = smgr->createDeleteAnimator(time+5);
Bullet->addAnimator(anim);
anim->drop();
for(int x = 0; x < 10; x++)
{
anim = smgr ->createCollisionResponseAnimator(ObjectSelector[x], Bullet, core::vector3df(1,1,1),
core::vector3df(0,0,0),
core::vector3df(0,50,0));
Bullet->addAnimator(anim);
anim -> drop();
}
anim = smgr ->createCollisionResponseAnimator(mapSelector, Bullet, core::vector3df(1,1,1),
core::vector3df(0,0,0),
core::vector3df(0,0,0));
Bullet->addAnimator(anim);
anim -> drop();
}
}
Any help would be appreciated
Thanks,
Bochek