Need help!

Need help on how to go to the next frame with 2 objects colliding using code

Probably the var that is undefined.

fixed it Screenshot 2024-04-18 205925

found a issue that it goes on 217 instead of 216 frame.Screenshot 2024-04-18 210429

the proper way to use this.hits(that) is to replace that with the name of the clip you are testing collision for.

suppose you have a clip named player and a clip named goal. in the player code, your update script might look like:

if(this.hits(goal)) {
    gotoNextFrame();
}

on that note, you are actually using gotoNextFrame() incorrectly: there should be no input, because it is just going to the “next” frame. you may be thinking of gotoAndStop(putFrameNumberHere), where you can choose the frame number.

so if, in this hypothetical example, the win screen is on frame 10, you can do:

if(this.hits(goal)) {
    gotoAndStop(10);
}
1 Like

Found another error.

also if your wondering whats the full code i putted for the player. its this:Screenshot 2024-04-18 212147

1 Like

you do not have a clip called goal. you have to name the clip to what you want.

i don’t know exactly what you are trying to make, so you might not want to call it goal. it might be an enemy, a shop, etc. so name it whatever fits.

find the clip of whatever you are checking collision with the player for (maybe it’s a goal). you need to put the name of the clip in the text box. then, in the this.hits thing, put in the same name.

Thank you! (the reason why it didnt work was because the name of the clip :sweat_smile:)

I tested it and once the player hits the goal it ends the game and says “error line 10”

errorline10-MadewithClipchamp-ezgif.com-video-to-gif-converter

is this thing called goal?

image

of course (ten)

Screenshot 2024-04-18 213306

Good news! It finally worked

3 Likes