Hello friends,
I am developing a FPS in which i am able to achive enemy attack through bullets,but unable to detect collision of bullet with character, in which i need to show health reduction of character
if(dbTimer() - shootingTimer > 400) //shots are fired every 160 milliseconds as long as player clicks mouse
{
/*resets the number of bullets to be fired, meaning that by
the time the last bullet is fired the first one should be way gone
and if not then its replaced*/
if(bulletCounter >= 20)
{
bulletCounter = 0;
}
//dbPositionSound(gunShot, dbObjectPositionX(mainWeapon),dbObjectPositionY(mainWeapon), dbObjectPositionZ(mainWeapon)); //position the gun shot sound at the gun
dbPlaySound(gunShot);
shootingTimer = dbTimer(); //resets the timer
dbShowObject(ebullets[bulletCounter][1]); //make the bullet appear again
ebullets[bulletCounter][3] = dbTimer();//sets bullets lifetime to 0, after x milliseconds stop it from moving
ebullets[bulletCounter][2] = 1;//tells program bullet is alive, used in hit detection
ebullets[bulletCounter][4] = 1400; //how long each bullet lives is check against bullets[3]
moveSmoothAtoB(enemyHolder[i][0],character , 0);
//SHADOW BULLET START this is the bullet that is seen
dbPositionObject(ebullets[bulletCounter][1], dbObjectPositionX(enemyHolder[i][0]), dbObjectPositionY(enemyHolder[i][0])+30, dbObjectPositionZ(enemyHolder[i][0]));
dbRotateObject(ebullets[bulletCounter][1], -dbObjectAngleX(enemyHolder[i][0]), dbObjectAngleY(enemyHolder[i][0]), dbObjectAngleZ(enemyHolder[i][0]));//make it face against the camera
dbRotateObject(ebullets[bulletCounter][1], -dbObjectAngleX(ebullets[bulletCounter][1]), dbObjectAngleY(ebullets[bulletCounter][1])-180, dbObjectAngleZ(ebullets[bulletCounter][1]));
//faces the bullet the right way around
//SHADOW BULLET END
// this is the bullet that is checked for collision
/* dbPositionObject(bullets[bulletCounter][0], dbObjectPositionX(sphereCam), dbObjectPositionY(sphereCam), dbObjectPositionZ(sphereCam));
dbRotateObject(bullets[bulletCounter][0], dbObjectAngleX(character), dbObjectAngleY(character)-180, dbObjectAngleZ(character));*/
bulletCounter++;//use the next bullet object after this one
if(SC_ObjectCollision(myCollisionHitBox,ebullets[bulletCounter][1]) == 1)
{
myHealth -= 7 + dbRnd(7);
}
// if(SC_ObjectCollision(enemyHitCube[i], myCollisionHitBox) == 1 && takingDamage == false ) //only hit him if hes alive
//{
//myHealth -= 7 + dbRnd(7); //does damage from 7 to 14
/*groanChosen = false;
takingDamage = true;
iveBeenHitTimer = dbTimer();*/ //makes sure the player doesnt take damage from multiple enemies at a the same time
/* }*/
}