• Hey! Guest! The 37th GMC Jam will take place between May 28th, 12:00 UTC and June 1st, 12:00 UTC. Why not join in! Click here to find out more!

GMS 2 Moving to the next room

Status
Not open for further replies.

Katsu

Member
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?
 

samspade

Member
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?
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.
 

Katsu

Member
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..
 

samspade

Member
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..
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.
 

Katsu

Member
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.
 

Katsu

Member
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);
 

Crazy Star

Member
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.
 

Katsu

Member
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);
 

samspade

Member
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);
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);
}
 

Katsu

Member
"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.
 

Attachments

samspade

Member
"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.
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?
 

Katsu

Member
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.
 

Katsu

Member
"// 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);
.
 

Katsu

Member
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..
 

samspade

Member
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..
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.
 

Katsu

Member
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:

Nocturne

Friendly Tyrant
Forum Staff
Admin
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.
 
Status
Not open for further replies.
Top