# Collision Detection

**URL:** https://forum.kirupa.com/t/collision-detection/38483
**Category:** Uncategorized
**Created:** [December 23, 2003, 5:27pm UTC](https://forum.kirupa.com/t/collision-detection/38483 "2003-12-23T17:27:14Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![UltimateDefiler](https://avatars.discourse-cdn.com/v4/letter/u/b782af/32.png) [@UltimateDefiler](https://forum.kirupa.com/u/UltimateDefiler)
#### Post date: [December 23, 2003, 5:27pm UTC](https://forum.kirupa.com/t/collision-detection/38483/1 "2003-12-23T17:27:14Z")

</div>

im making a game and so far its been pretty easy, but i ran into a problem detecting when a bullet hits a guy. I duplicated both the bullet and the guy so i figured i could put code into the bullet and nest a do loop inside to test which guy i hit. but the do loop runs too slowly and only detects a collision every once in a while. Is there any way to test if any guy duplicated is hit?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [December 23, 2003, 5:39pm UTC](https://forum.kirupa.com/t/collision-detection/38483/2 "2003-12-23T17:39:46Z")

</div>

as 4 bullet when guys are named “guy1” & “guy2”:

```auto
onEnterFrame = function() {
for(i=1;i<3;i++) {
this.hitTest(_root["guy"+i]) ? trace('hit!') : null;
}
}

```

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [December 23, 2003, 5:49pm UTC](https://forum.kirupa.com/t/collision-detection/38483/3 "2003-12-23T17:49:18Z")

</div>

ahhh, but thats where the problem lies . . . with 20 bullets on the screen and about the same number of guys, the system can’t process it all. So my plan was to test if any guy was hit and then go from there.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [December 23, 2003, 10:48pm UTC](https://forum.kirupa.com/t/collision-detection/38483/4 "2003-12-23T22:48:45Z")

</div>

my script finds out if bullet hits any of those guys…
