hitest help
- JCesta
-
JCesta
- Member since: Jul. 8, 2005
- Offline.
-
- Forum Stats
- Member
- Level 09
- Blank Slate
i have an MC of a boss. the boss has different parts that damage the player if he touches them but the parts get damaged if the bullet touches them.
onClipEvent (enterFrame) {
if (this.hitTest(this._parent.player)) {
_root.health -= 10;
}
if (this.hitTest(_root.bullet)) {
play():
}
}
for some reason this doesnt work, i check all my instances. could it be because the bulet is a duplication?
- JeremysFilms
-
JeremysFilms
- Member since: Feb. 18, 2005
- Offline.
-
- Forum Stats
- Member
- Level 18
- Blank Slate
What doesn't work? Does the play() command not work? If so just change it to _root.play();
- JCesta
-
JCesta
- Member since: Jul. 8, 2005
- Offline.
-
- Forum Stats
- Member
- Level 09
- Blank Slate
no, the play command is supposed to take the part of the boss and play the frame were it explodes. the part of the boss is were this code is in.
- ShotInTheHead
-
ShotInTheHead
- Member since: Dec. 20, 2002
- Offline.
-
- Forum Stats
- Member
- Level 31
- Blank Slate
looks like the problem is the part taht says this._parent.player
replace it with _root.player (and you never need to use "this" in nearly anything)
- JCesta
-
JCesta
- Member since: Jul. 8, 2005
- Offline.
-
- Forum Stats
- Member
- Level 09
- Blank Slate
no that just fixed the health but the bullets still dont do anything
- ShotInTheHead
-
ShotInTheHead
- Member since: Dec. 20, 2002
- Offline.
-
- Forum Stats
- Member
- Level 31
- Blank Slate
if youre duplicating your bullets, then chances are its instance naem problems. you cnatj ust name em all bullet. its gonna be bullet1 bullet2 bullet3 etc. then run a loop to check for each bullet##
for(i=0;i<30;i++) {
//checks for anything named bullet1 to bullet30
if (this.hitTest(_root["bullet"+i])) {
//put your scripts here
}
}

