Collision detection problems

Whenever I try do do collision detection it doesn’t detect the collision with the shape within the movieclip, but the rectangle border around the movieclip itself… how can I avoid this?\r\rwww.chickensnack.com

hit test has some parameters you can set. They take more processor power which is why it’s default is set to detect bounding box collision detection rather than shape.\r\rI believe it’s\r\rfirstMovieClip.hitTest(secondMovieClip,true);\r\rwhere true is a boolian value which tells the hit test to work on shapes rather than bounding boxes.

Hmm… that doesn’t seem to work…\rI am making a game where you lose if you get spotted by the police (go within their range of sight which is displayed as blue). It would be much better if it could detect the collision with that shape instead of a rectangle.\rHere’s a simple example:\r

i’m afraid you can only evaluate the shape if you’re hitTesting against a coordinate, it won’t fly with a movie.\r\ryou could use the center point of “you” as the coordinates:

 \r\rif(_root.police.hitTest(_root.you._x,_root.you._y,true){\r\r   ... they got me ...\r\r}else{\r\r   ... they missed me ...\r\r}

\ror if you’re feeling ambitious, you could write your own hitTest routine. remember the equation for a circle? neither do i. ;)\r\rgood luck!

ahhhhhh you’re so right… \r\r<~ slapping head. I was having problems with this eariler… I think that’s why.

Thank you so much suprabeener! it works like a charm!\r\r <embed src=“http://www.chickensnack.com/flash/gtrc-collision.swf” quality=high pluginspage=“http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash” type=“application/x-shockwave-flash” width=“550” height=“400”>\r </embed>

hey chickensnack… how about displaying your final code, so the rest of us can give it a gander…?\r\rThanks!\r

Here’s the code (its placed in the actions of “You” not the frame):\r\ronClipEvent (enterFrame) {\r if (_root.police.hitTest(_root.you._x, _root.you._y, true)) {\r _root.text = “You’ve been spotted!”;\r } else {\r _root.text = “You’re OK.”;\r }\r}\r\rThe instance name of the police vision name is “police”.\rYou is “you”, obviously.\rAnd the text field variable is “text”\r\rStill working towards an actual game! I made it so that if you collide with the car itself, it causes the health thing to say you’re dead.\r<embed src=“http://www.chickensnack.com/flash/collision3.swf” quality=high pluginspage=“http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash” type=“application/x-shockwave-flash” width=“550” height=“400”>\r</embed>

nice. :slight_smile: