Be a Supporter!

Issue with collision detection

  • 304 Views
  • 3 Replies
New Topic Respond to this Topic
JonesRambuk
JonesRambuk
  • Member since: Jul. 14, 2004
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Issue with collision detection 2009-03-25 10:39:07 Reply

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
Response to Issue with collision detection 2009-03-25 10:49:40 Reply

Did you give them the correct instance names?


BBS Signature
Denvish
Denvish
  • Member since: Apr. 25, 2003
  • Offline.
Forum Stats
Member
Level 46
Blank Slate
Response to Issue with collision detection 2009-03-25 10:54:59 Reply

Make sure it's being run on enterFrame, and also put in a trace to see whether the hitTest is registering or not


- - Flash - Music - Images - -

BBS Signature
flaminggranny
flaminggranny
  • Member since: Sep. 12, 2008
  • Offline.
Forum Stats
Member
Level 10
Blank Slate
Response to Issue with collision detection 2009-03-25 11:40:52 Reply

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.


BBS Signature