Issue with collision detection
- JonesRambuk
-
JonesRambuk
- Member since: Jul. 14, 2004
- Offline.
-
- Forum Stats
- Member
- Level 09
- Blank Slate
Hey everyone.
I'm having an issue with making my player die when ever it hits an enemy.
so far I've tried almost all the collision scripts I could find on the net, but none would work.
if(this.hitTest(_root.player)){
_root.player.gotoAndStop(2);
}
I've tried this script on the enemy, and opposite on the player.
The enemies and the player are on seperate layers since I reuse the player for all stages, and so the player has one key frame lasting 10 frames while the enemies are divided on 10 representing each stage.
I'm able to play through the game which is set to be on a timer for each stage. But I have yet to solve this gameover issue I'm having. Any ideas and suggestions would be extremely helpfull.
- Magical-Zorse
-
Magical-Zorse
- Member since: May. 10, 2008
- Offline.
-
- Forum Stats
- Member
- Level 39
- Melancholy
Did you give them the correct instance names?
- Denvish
-
Denvish
- Member since: Apr. 25, 2003
- Offline.
-
- Send Private Message
- Browse All Posts (15,977)
- Block
-
- Forum Stats
- Member
- Level 46
- Blank Slate
Make sure it's being run on enterFrame, and also put in a trace to see whether the hitTest is registering or not
- flaminggranny
-
flaminggranny
- Member since: Sep. 12, 2008
- Offline.
-
- Forum Stats
- Member
- Level 10
- Blank Slate
After you do what Denvish said, look up some tutorials on proper box collision or hitTestPoint. Using the entire animation of a character for hitTest causes really inaccurate collision.



