PDA

View Full Version : hitTest not working for plane collision



ironikart
April 4th, 2003, 01:39 AM
I can't seem to get hitTest to work for the plane in my little game. The code I'm using in the plane MC is:
if (_root.player.hitTest("_root.badguy"))
playerhealth -= 20;
}
if (playerhealth<1) {
_root.gotoAndPlay("gameover",1);
}
{

I want to the badguy plane to hit the player's plane and take a subtraction from the player's heath. I've fiddled around with using "this" instead of the full path of the playerMC - no success. My hitTest is working fine for the bullets!

I've attached the fla if you want to have a look at it. It might make more sense than my rather rushed explanation.

lostinbeta
April 4th, 2003, 01:49 AM
Your hitTest works fine. I used a trace to test it. Try this...

if (_root.player.hitTest("_root.badguy")) {
trace("hit")
playerhealth -= 20;
}
if (playerhealth<1) {
trace("done")
_root.gotoAndPlay("gameover",1);
}

You have it gotoAndPlay that goes to a new scene.

What sucks about scenes is that they suck. Haha, sad but true. To get your scene targetting to actually work right give frame 1 in the scene gameover a frame label. Lets say "gameOver" (no quotes). Then target it with _root.gotoAndPlay("gameOver") (use quotes this time)

ironikart
April 4th, 2003, 02:07 AM
Thanks for that. I thought theoritically that a new scene should play just the same as the current one. Ah well, it works fine now. Thanks again for your expertise and fast response!

lostinbeta
April 4th, 2003, 02:17 AM
Yeah, TECHNICALLY it shoulda worked, but Flashs support for it's own Scenes system sucks big time, it's so buggy it is unbelievably annoying. Mainly playing them is a pain, but as long as you always use frame labels and gotoAndPlay them, it should work, that is the best workaround to playing multiple scenes.