Copy link to clipboard
Copied
I am trying to make a simple maze game, but the collision detection is not working. I have the player moving with the arrow keys, and I am trying to make it so that when the player collides with the wall, it goes to a certain frame. I have this code in the wall movie clip:
onClipEvent (enterFrame) {
if (_root.player.hitTest(this))
{
gotoAndStop("death");
}
}
The player's instance name is "player" and the wall's instance name is "walls1". When the player hits the wall, the player just goes right through it. I'm pretty sure it's something with the collision, not the "gotoAndStop("death");" because I tested it with "gotoAndStop(5);" and the player still goes through the wall.
If someone could help me, I would really appreciate it. Thanks in advance!
1 Correct answer
What object are you expecting to goto frame 5 ("death")?
You should move your code to the main timeline and target the objects.
Copy link to clipboard
Copied
What object are you expecting to goto frame 5 ("death")?
You should move your code to the main timeline and target the objects.
Copy link to clipboard
Copied
Thank you so much! The problem was it was trying to go to frame 5 in the object, not the timeline.
Copy link to clipboard
Copied
You're welcome

