# Hit Detection question

**URL:** <https://forum.kirupa.com/t/hit-detection-question/322173>\
**Category:** flash\
**Created:** [May 12, 2011, 9:53pm UTC](https://forum.kirupa.com/t/hit-detection-question/322173 "2011-05-12T21:53:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![designCannon](https://avatars.discourse-cdn.com/v4/letter/d/3ec8ea/32.png) [@designCannon](https://forum.kirupa.com/u/designCannon)\
**Post date:** [May 12, 2011, 9:53pm UTC](https://forum.kirupa.com/t/hit-detection-question/322173/1 "2011-05-12T21:53:52Z")

</div>

I’m making an educational side-scrolling game where basically one animal “eats” other aquatic animals on the stage. Right now, it counts as a hit when anywhere on the entire movieclip for the character (“char”) touches one of the prey. How do I make just the head count?

```auto
function preyHandler(event:Event)
            {// handler for prey getting eaten
                for (var i:int=0; i<allPrey.length; i++)
                {
                    if (event.target.hitTestObject(char))
                    {
                        //trace ("hit test successful");
                        event.target.width = 0;
                        event.target.height = 0;
                        preyCount++;
                        trace("score +1");
                        score.text = String(preyCount);

                        event.target.removeEventListener(Event.ENTER_FRAME, preyHandler);
                    }
                }
            }//end preyHandler

```

I made a clip inside “char” called “head” and tried

```auto
 if (event.target.hitTestObject(char.head)) 

```

and event just

```auto
 if (event.target.hitTestObject(head)) 

```

but those made crazy errors.

What is the correct way to do this? Any help appreciated.
