# Bullet-target interaction

**URL:** <https://forum.kirupa.com/t/bullet-target-interaction/215892>\
**Category:** Uncategorized\
**Created:** [February 11, 2007, 9:17pm UTC](https://forum.kirupa.com/t/bullet-target-interaction/215892 "2007-02-11T21:17:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![xytor](https://avatars.discourse-cdn.com/v4/letter/x/90ced4/32.png) [@xytor](https://forum.kirupa.com/u/xytor)\
**Post date:** [February 11, 2007, 9:17pm UTC](https://forum.kirupa.com/t/bullet-target-interaction/215892/1 "2007-02-11T21:17:40Z")

</div>

I’m wondering if there is a more efficient way of creating bullets and their interaction with targets than the example below.  
Bullet is created from here:

```auto
onClipEvent (enterFrame) {
 if (Key.isDown(Key.SPACE)) {
  var b = _root.attachMovie("Bullet", "Bullet", _root.getNextHighestDepth(), {_x:this._x, _y:this._y});
  b.onEnterFrame = function() {
   this._y -= 40;
  };
 }
}

```

The target deals with the bullet like this:

```auto
onClipEvent(enterFrame){
 if(this.hitTest(_root.Bullet)){
  removeMovieClip(_root.Bullet);
 }
}

```

This sample code seems simple, but when you get into multiple targets, and explosions on impact, the bullets start to go through targets, especially if the target is dynamically created… among other problems.

There must be a better way.
