Hi,
I’ve been making a doom shooter game in my free time, it’s top-down view, and i have the shooting system like i have a shooter button that shoots when the player presses it. There are zombies which the player must kill, but i have the problem, that i can’t find a way to remove the bullet, when it hits the zombie. (so the bullet won’t “fly” above/through the zombie.)
I know about the method of using bullet.removeMovieClip(); but it only works, if there’s only one bullet on the screen, and the problem is that i want to have more weapons, some of them with a fast shoot-rate, so this way wouldn’t work.
I also tought about scripting the bullet movieclip itself, but then it would be annoying, because i would need to set an instance name to all the enemies, and script it for all of them, so this isnt the right way either.
Here’s the shooter button’s code:
on(press)
{
_root.player.body.wep.weapon.play()
var bullet:MovieClip = _root.attachMovie("bullet", "bullet_"+_root.getNextHighestDepth(), _root.getNextHighestDepth());
var point = {x:player.bullet_spawn._x, y:player.bullet_spawn._y};
player.localToGlobal(point);
// now use point.x and point.y as coordinates for bullet in conjunction with the rotation you just gave it.
bullet._x = point.x;
bullet._y = point.y;
bullet._rotation = player._rotation
bullet.onEnterFrame = function() {
this._x += Math.cos(this._rotation*Math.PI/180)*_root.bulletSpeed;
this._y += Math.sin(this._rotation*Math.PI/180)*_root.bulletSpeed;
if (_root.wall.hitTest(this._x, this._y, true)) {
this.removeMovieClip();
}
}
}
Any ideas how i could do it?