Author Topic: Bullets colliding when they are shoot after a reset  (Read 784 times)

im_making_games

  • Member
  • **
  • Posts: 14
  • Karma: +0/-0
    • View Profile
Hi, I have the bullet working like this in an enemy class

Code: [Select]
if (_curFrame == 10)
{
bullet.exists = true;
bullet.velocity.x = -400;
bullet.velocity.y = 12;
if (!bulletDelay.isRunning)
          bulletDelay.start();
}
I have this happen at the end of bulletDelay
Code: [Select]
bullet.exists = false;
bullet.velocity.x = 0;
bullet.velocity.y = 0;
play("enemyDoingStuff");
this is happening every frame when the frame isn't 10 on the enemy (which is a good duration within "enemyDoingStuff")
Code: [Select]
bullet.x = x - 20;
bullet.y = y +8;
The problem is, when the bullets fire again from the enemy, my character gets insta-hit by the bullet, as if the teleport back to the enemy is actually a very fast movement and not a teleport. Anything I can do to fix this?

wg/funstorm

  • Global Moderator
  • Key Contributor
  • *****
  • Posts: 596
  • Karma: +0/-0
    • View Profile
    • Funstorm
Re: Bullets colliding when they are shoot after a reset
« Reply #1 on: Fri, Aug 31, 2012 »
It doesn't look like you are resetting the position of the bullet when you reactivate it. So it will be reactivated exactly in the same spot where it was when you killed it. I think you just need to put a bullet.x = enemy.x + enemy.width; or something like that where you reactivate your bullets.