hitTest

Hey people,
I am trying to get a MC to play when it collides with another MC named “light”. Here is my code. It is on the MC that I want to play (called “rap”)
[AS]
onClipEvent (enterFrame) {
if (this.hitTest(_root.light)) {
this.gotoAndPlay(2);
} else {
this.gotoAndStop(1);
}
}
[/AS]

the two MCs are called “rap” which is on the fuzzButt layer, and “light” which is just below it in the light layer.
Any help is appreciated. thanks!

CLICK HERE FOR THE ZIP FILE

just downloaded it, im gonna try to see what i can do…

did you try using the coordinates of your movie clip instead?

like:

onClipEvent (enterFrame) {
        if (this.hitTest(this._x, this._y, true)  {
                this.gotoAndPlay(2);
        } else {
                this.gotoAndStop(1);
        }
}

yeah, i tried doing that first (only reading the coordinates on light, cuz thats the one that’s moving), but i couldn’t get it right, because, well, i dunno, it’s a bad day in flash for me i guess. lol! actually, i tried doign something like
[AS]
onClipEvent(enterFrame) {
if (_root.light._X>60 && _root.light._X<65)
{
this.gotoAndPlay(2);
} else {
this.gotoAndStop(1);
}
[/AS]
but… no workie. thanks for takin a look liam :beam:

haha yeah oops i messed up my code!

ill have it workin for u shortly. :slight_smile:

you’re the best :flower:

onClipEvent (enterFrame) {
	if (_parent.light.hitTest(this._x, this._y, true) && !hit) {
		this.gotoAndPlay(2);
	} else if (!_parent.light.hitTest(this._x, this._y, true) && hit) {
		this.gotoAndStop(1);
	}
	hit = _parent.light.hitTest(this._x, this._y, true);
}

:wink:

thank you thank you thank you!!!
you’re the best too! :wink:

… I know that. :stuck_out_tongue: [size=1]just kidding!![/size]

You’re welcome. =)

Edit. I modified the code a bit to save CPU usage… nothing really important but still. :slight_smile: