GameMaker: Studio

GameMaker: Studio

View Stats:
flowersnax Dec 5, 2016 @ 6:20pm
Room Exit Help? (SOLVED)
So I'm struggling to create an object that will allow the player to exit the house into the room they were previously in. As I have it right now, it's just an object with the event collision (with the player character) and what it's supposed to do when it detects said collision is send the player to the previous room. The problem is, it does nothing. What am I doing wrong, and how can I fix it?
Last edited by flowersnax; Dec 11, 2016 @ 6:39pm
< >
Showing 1-15 of 19 comments
The Winter Bud Dec 6, 2016 @ 6:38am 
depends really. You only need one collision event between them. either in the tranport object(the one taking him to town) or in the player. Either one will work. In that collision event you can move the player to the previous room with
// if in the player object room_goto_previous();
- OR -
// if in the transporter object with(other){ room_goto_previous(); }

NOTE: I don't know if you know this or not, but when returning to the previous room, if you want the room to be the way you left the room, then in the room editor you would select the "persistant" check box. This makes the room remember the way you left it and will remain the way you left it when you return.

EDIT:
now the 'previous' room that this function calls is not the room the player came from but the room that is one room up the list in your room resources
example:
rm_opening
rm_menu
rm_playerSelect
rm_house
rm_town
rm_forest

now let's say the player came from town to his house. So from the house if the player goes to the previous room, he'll go to the rm_playerSelect room because that is the room prior to the the rm_house in the resource list.

If you wanted him to go to the rm_town, then you would have to use a different function
room_goto(rm_town) or room_goto_next() because rm_town is listed after rm_house. but if you add a room in between them then you'll have to use room_goto(rm_town) anyways, so it's the function that shoudl be used in the first place.
Last edited by The Winter Bud; Dec 6, 2016 @ 6:44am
flowersnax Dec 6, 2016 @ 1:23pm 
Thanks, I'll try that!
flowersnax Dec 6, 2016 @ 4:25pm 
Ok, I tried the first one with the room name instead of previous, and it still didn't work. Any other ideas?
The Winter Bud Dec 7, 2016 @ 11:25am 
I don't know what you mean "it still don't work", so I am out of ideas
flowersnax Dec 7, 2016 @ 1:50pm 
Oops, I meant that what I inputted still didn't transport the player back to the room I intended.
The Winter Bud Dec 7, 2016 @ 7:22pm 
All I can think of is that you either put the code in the wrong event, or you have code conflicting with it. My suggestion is copy/paste the object information in a "code" block so we may see all that is intailed with your object.
Change goto_previous_room to goto_room(ROOM_NAME).

Like already mentioned, goto_previous_room goes to the room one up in your room list in the editor and NOT the room your player was last in.
flowersnax Dec 8, 2016 @ 1:21pm 
Information about object: roomexit Sprite: Solid: true Visible: false Depth: 0 Persistent: false Parent: Children: Mask: No Physics Object Collision Event with object Wicker: execute code: // if in the player object room_goto(Play_Room);

here ya go!
The Winter Bud Dec 8, 2016 @ 7:20pm 
Thanks ultia. The code you supplied helps me understand that you have a room resource called "Play_Room". You also have an object called "Wicker" and another object called "roomexit". Now, what do you want to go to the "Play_Room"? The wicker object? If so, then change the code a little to look like this
with(other){ room_goto(Play_Room); }

Thing that may be wrong that I can't see.
1. Play_Room is not a room - room_goto() wants a room to go to
2. There is another resource called "Play_Room" and it is conflicting - rename resources so they are unique
3. You have a roomexit in the other room bringing you back to the room you left and causing an infinite loop where the wicker goes back and forth from the two rooms.
Last edited by The Winter Bud; Dec 8, 2016 @ 7:21pm
flowersnax Dec 9, 2016 @ 1:04pm 
Thanks, dennis! I'll try that :D
flowersnax Dec 9, 2016 @ 1:07pm 
Ok that didn't work, either. I don't know what to do. I don't have anything else named "Play_Room" and that is indeed a room. I don't have another roomexit outside the room, either.
The Winter Bud Dec 9, 2016 @ 1:14pm 
hmm that's weird. let's try something shall we
in teh create event of the wicker object and the roomexit object put this
show_debug_message(object_get_name(object_index)+" --> create event");

then in any other event put the same code, but change the text at the end of the string to read
--> name of event
example:
+" --> collision with Wicker event"
-- OR --
+" --> Arrow right Key Pressed event"

then run the game. try to collide the wicker with the roomexit. once you have finished your simulation, in the code editor at the bottom should be the debug text we wanted to see. it should say something like this
roomexit --> create event
Wicker --> create event
and so on. each object telling you when they were in their event. If your object has a step event then that is what we'll see most of, but what we're looking for is at the end of the list, we should see a line that looks something like this

roomexit --> collision with Wicker event

EDIT: can you tell me in words how you know you are not moving to the next room? are the two rooms different at all? Is there a way to know for sure that you are in fact not moving to antoehr room?

you can try changing the debug line to this
show_debug_message(object_get_name(object_index)+" - ROOM: "+room_get_name(room)+" --> event name");
Last edited by The Winter Bud; Dec 9, 2016 @ 1:19pm
flowersnax Dec 9, 2016 @ 1:50pm 
I walk right into where the object should be, an the player doesn't move. it basically leaves me trapped in the room.
The Winter Bud Dec 9, 2016 @ 2:01pm 
if you are not getting the line
roomexit --> collision with Wicker event
then that means your movement code is not allowing you to collide with roomexit object (turn off solid - no need for that anyways)
if you do get that line then that means some other object's code is preventing you from moving on to another room or bringing you back and forth. It will be noticible in teh debug text
if only one line of the collision event appears then something is interfearing and not letting it move on, if there are a lot of collision event lines appear then the object is stuck on teh roomexit object or there is an infinite loop making it go back and forth from one room to the other.
flowersnax Dec 11, 2016 @ 4:11pm 
So I was out all day yesterday, so I didn't get the chance to do the debug thing. I did, however, change the code to this.
if collision_circle(roomexit.x, roomexit.y, 15, Wicker, false, true) { room_goto(Play_Room) }
I made some progress with it, although that progress is simply transporting the player. The problem is, it doesn't transport me back to where I was before ("Play_Room"), but back to where I was originally in the house.
< >
Showing 1-15 of 19 comments
Per page: 1530 50