GMS 2 Moving to the next room

Discussion in 'Programming' started by Katsu, May 14, 2019.

Thread Status:
Not open for further replies.
  1. Katsu

    Katsu Member

    Joined:
    Apr 30, 2019
    Posts:
    25
    Hello, so im curious I have an object I'm actually using three striped objects.. All the same, I wondering if after I make all three striped objects disappear I can go to the next room?.. I've looked up videos and notes on it, am i missing something?
     
  2. Binsk

    Binsk Member

    Joined:
    Jun 22, 2016
    Posts:
    544
  3. samspade

    samspade Member

    Joined:
    Feb 26, 2017
    Posts:
    1,931
    Your question is unclear and difficult to answer for that reason. If the link to room functions in the manual doesn't answer your question, I would try rephrasing it to be more specific and showing what you've tried so far.
     
  4. Katsu

    Katsu Member

    Joined:
    Apr 30, 2019
    Posts:
    25
    I'm wanting to move three boxes into 3 objects I've created so after all three of these objects disappear they take the character to the next room.. I've tried to use the notes above and it will start the game on the second level, so I don't know what I'm doing wrong..
     
  5. samspade

    samspade Member

    Joined:
    Feb 26, 2017
    Posts:
    1,931
    That makes more sense. It sounds like you have three boxes, and three places you can put these boxes, and if you put one box in each place to put a box, the player goes to the next room. However, this probably could be solved in many ways and you haven't showed us anything about how your code already works. One solution might be:

    Code:
    
    if (number_of_boxes_used >= 3) {
        room_goto(room_2);
    }
    
    
    But whether the above is helpful, would be entirely depending on many other things. In other words, you'll need to do the second thing I said which is: show us what you've tried so far (which is technically one of the forum guidelines).

    https://forum.yoyogames.com/index.php?threads/programming-forum-guidelines.27723/
    Posting code on the Programming Forum: Do's and Dont's.
     
  6. Katsu

    Katsu Member

    Joined:
    Apr 30, 2019
    Posts:
    25
    I thought I did show what I did, hrrmm i,might of deleted it, I tried room_goto_room(lvl1); in an if statement and it would direct yak me to the next room automatically when I started the game, but I'll try what you posted though.
     
  7. Katsu

    Katsu Member

    Joined:
    Apr 30, 2019
    Posts:
    25
    this is the code i have in my end level object
    for the collision for the red boxes going into the end level object.

    "// end of level goal//

    audio_play_sound(snd_goal, false, false);


    //Destroys boxes on impact!
    instance_destroy(other);"


    for the end level objects i have this code lying in there to destroy the instances after the boxes hit them,

    //destroys striped object//
    instance_destroy(other);
     
  8. Crazy Star

    Crazy Star Member

    Joined:
    Nov 21, 2017
    Posts:
    79
    The end level event is fired not when the level should stop, but rather when the level has stopped.

    Edit:
    If that's in any way relevant.
     
  9. Katsu

    Katsu Member

    Joined:
    Apr 30, 2019
    Posts:
    25
    so here is the code i used in the collision with the red box, i tried it and it gives me an error.
    "if (object4 >= 3) {
    room_goto(other);
    }"
    the error

    Unexisting room number: 100006
    at gml_Object_object4_Collision_8b2f7044_b1ed_463c_a100_dcebec170a0b (line 16) - room_goto(other);
     
  10. samspade

    samspade Member

    Joined:
    Feb 26, 2017
    Posts:
    1,931
    To be honest, I'm still not entirely clear what you're trying to do. And while you're certainly providing more information, it's still difficult if not impossible to figure out. Also, I don't see anything that has a room goto in the code. Also, I explicitly said in my post that the code I posted wouldn't work and that it was an illustration of how it is impossible to advise without sufficient knowledge of what your code looks like. Your version of my code also isn't an accurate copy and you used room_goto with an object index which is why you are getting an error.

    You need to provide a much better picture of what you're trying to do and you should follow the forum rules for posting (see my previous post).

    My current guess is that you have one or mutliple of something called end level goal. This object has a collision event with striped object. This collision event destroys striped object. You want the player to go to the next level when all striped objects are destroyed. If this is the case maybe you can do:

    Code:
    
    if (instance_exists(whatever your box object is called) == false) {
        room_goto(whatever the name of the room is you want to go to);
    }
    
    
     
  11. Katsu

    Katsu Member

    Joined:
    Apr 30, 2019
    Posts:
    25
    "if (roomdoor >= 3) {
    room_goto(other);
    }"
    this is it right here, i tried to use this and it would give me an error. im trying to move three boxes into this door so i can move to the next level. so i wrote it many ways and it still wont work, but i wrote it like what i have above and it gives me an error when i push the red blocks into a door. which is noted above, so i dont know why its doing that..
    here is the image of my layout.
     

    Attached Files:

    • gml .jpg
      gml .jpg
      File size:
      283.8 KB
      Views:
      11
  12. samspade

    samspade Member

    Joined:
    Feb 26, 2017
    Posts:
    1,931
    Not only is that not what I posted, it is again an incorrect use of that functions. You also again ignored most of what I said in the prior post and are still not following the forum rules on posting code.

    Still, if red_crate is the name of the object and lvl_2 is the name of the room, try putting this in a step event:

    Code:
    
    if (instance_exists(red_crate) == false) {
       room_goto(lvl_2);
    }
    
    show_debug_message("Number of red crates: " + string(instance_number(red_crate)));
    
    
    What does the output window say?
     
  13. Katsu

    Katsu Member

    Joined:
    Apr 30, 2019
    Posts:
    25
    I have been trying everything you've given me for ideas when i put the above code in, it runs, and i place all the blocks into the striped blocks it doesn't show anything.
     
  14. samspade

    samspade Member

    Joined:
    Feb 26, 2017
    Posts:
    1,931
    Please show where you posted the code, and what you code you posted.
     
  15. Katsu

    Katsu Member

    Joined:
    Apr 30, 2019
    Posts:
    25
     
  16. samspade

    samspade Member

    Joined:
    Feb 26, 2017
    Posts:
    1,931
    Sorry, post the code you most recently tried, and where you posted it.
     
  17. Katsu

    Katsu Member

    Joined:
    Apr 30, 2019
    Posts:
    25
    That's the latest, then what you had me replace the last part of what I had with what you wanted me to try. It will not allow me to go to the next room at all, unless it's because I don't have an instance to the next room or a door..
     
  18. samspade

    samspade Member

    Joined:
    Feb 26, 2017
    Posts:
    1,931
    I'm confused, what you posted had none of the code I said you should add and isn't anything close to what I said you should try.
     
  19. Katsu

    Katsu Member

    Joined:
    Apr 30, 2019
    Posts:
    25
    Ohh you wanted the stuff I tried I'll get it when im,home

    // end of level goal//

    audio_play_sound(snd_goal, false, false);


    //Destroys boxes on impact!
    instance_destroy(other);


    //questionable coding for room change?


    if (instance_exists(object4) == false) {
    room_goto(lvl_2);
    }

    show_debug_message("Number of red crates: " + string(instance_number(red_crate)));
     
    Last edited by a moderator: May 23, 2019
  20. Nocturne

    Nocturne Friendly Tyrant Forum Staff Admin

    Joined:
    Apr 13, 2016
    Posts:
    6,736
    Hi there! This topic is closed and your account has been banned as it appears you are not using a legitimate copy of GameMaker Studio 2. If this is not the case or you believe there has been some mistake then please contact the YoYo Games helpdesk with your licence details (and link to this topic) and you will be permitted back on the forums.
     
Thread Status:
Not open for further replies.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice