GM:S 1.4 room change is acting crazy

Discussion in 'Programming' started by pixeltroid, Sep 11, 2019.

  1. pixeltroid

    pixeltroid Member

    Joined:
    Jul 23, 2016
    Posts:
    658
    I had a working room change system in which upon touching a "door" object I could easily switch rooms and go to a specific area in a specific room. Now, its acting funny.

    Its now warping me to a different location....either in the room I was supposed to go to or it sends me to next room. Its really driving me nuts as I can't seem to figure out what's causing this.

    Here's what I've done so far:

    - I cleared the cache
    - I double checked the co-ordinates and room name as set in the door objects creation code
    - I made sure that there are no other objects with room change code in the area of the room that I am supposed to enter.

    I know it cannot be an issue with my code because it has been working fine for more than a year. This is a problem that has only developed in the last few days

    I'm worried about things like project or software corruption. :/

    What should I do??? Please advice!
     
  2. Binsk

    Binsk Member

    Joined:
    Jun 22, 2016
    Posts:
    582
    What have you done in the last few days that relate to room switches, location changes, or door object changes?

    Go through the code you've changed and see if you can find something that might have unintended consequences.
     
  3. pixeltroid

    pixeltroid Member

    Joined:
    Jul 23, 2016
    Posts:
    658
    I haven't done anything but use the code as-is. Except change the X,Y coordinates and room name as per my requirements. It's been working fine for more than a year, so I wouldn't dare mess with it.

    It's only since yesterday that I started to notice issues and errors.
     
  4. spoonsinbunnies

    spoonsinbunnies Member

    Joined:
    Aug 24, 2018
    Posts:
    109
    show us your code,fresh eyes don't usually have the information jumping the creator does when speedreading code that causes us to overlook the same flaw 100 times, I remember when in gamemaker06-08(as in before studios 1, yeah im an old noob) there were corruption problems but I haven't encountered any corruption recently.
     
  5. pixeltroid

    pixeltroid Member

    Joined:
    Jul 23, 2016
    Posts:
    658
    @spoonsinbunnies

    here are the codes.


    obj_roomchange creation code
    Code:
    new_x = 0;
    new_y = 0;
    new_room = noone
    
    obj_roomchange creation code in room

    Code:
    new_room = room_2;
    new_x = 48
    new_y = 510
    

    obj_hero collision code with obj_roomchange

    Code:
    if (room_exists(other.new_room)) {
    room_goto(other.new_room);
    x = other.new_x;
    y= other.new_y;
    }
    
    I am using this exact same code across 2 projects. It works in one but not the other.
     
  6. TsukaYuriko

    TsukaYuriko Q&A Spawn Camper Forum Staff Moderator

    Joined:
    Apr 21, 2016
    Posts:
    1,580
    Add a debug message to the collision code that outputs the destination room and coordinates. Is this output consistent with the actual changing of rooms?
    If you add a security check to only change rooms if the destination room is the one you want your test door to lead to (can be hard-coded), does the room change still occur? If so, does it still sometimes lead you to the wrong destination?

    Just to rule out that this is actually the thing that's changing rooms and that there isn't some entirely unrelated code running that's somehow messing things up...
     
  7. pixeltroid

    pixeltroid Member

    Joined:
    Jul 23, 2016
    Posts:
    658
    How do I do this exactly?
     
  8. TsukaYuriko

    TsukaYuriko Q&A Spawn Camper Forum Staff Moderator

    Joined:
    Apr 21, 2016
    Posts:
    1,580
    show_debug_message the values of the room change instance's new_room, new_x and new_y.
     
  9. pixeltroid

    pixeltroid Member

    Joined:
    Jul 23, 2016
    Posts:
    658
    ok. I did it. Its showing the message in the compiler window but its still sending me to the wrong location.
     
  10. spoonsinbunnies

    spoonsinbunnies Member

    Joined:
    Aug 24, 2018
    Posts:
    109
    if by location you mean wrong room and not wrong x/y one thing to consider are you landing on another door(or even close enough that your persistent speed pulls you into it) in the target room so maybe jumping twice?
     
  11. pixeltroid

    pixeltroid Member

    Joined:
    Jul 23, 2016
    Posts:
    658
    Nope. I have made sure. The player lands well away any object with code. He is at least 64 pixels away from the door object that leads back to the room I came from.
     
  12. Catan

    Catan Member

    Joined:
    Jun 20, 2016
    Posts:
    679
    So you are saying that you collide with an instance of obj_roomchange that defines, for example, new_x = 48 and new_y = 510 and you are not seeing those values as result of the show_debug_message call? If not, what values are you seeing? Moreover, do you get just one line as output to the console or multiple ones for a single room change?

    Debugging your own code is already difficult enough, debugging someone else's is even worse. Try going into a bit more detail and include code / debug code used when possible, we need this info in order to help you.
     
    Last edited: Sep 12, 2019
  13. spoonsinbunnies

    spoonsinbunnies Member

    Joined:
    Aug 24, 2018
    Posts:
    109
    Im not sure then tbh maybe other is getting confused? I try to avoid it if I can by using something along the lines of this in step
    Code:
    a=instance_place(x,y,obj_roomchange)
    if a!=-4
    {
    x=a.new_x
    y=a.new_y
    room_goto(a.new_room)
    }
    
    I doubt this will help either, just the equivlant of try the same thing a different way and pray to the rl rng, only other thing I can think is that your character moves before the room change ussually so if theres a two doors in the first room and the second happens to be where the one your going through sets you in room 2, it could be superceeding the first room jump, but otherwise im honestly at a loss.
     
  14. pixeltroid

    pixeltroid Member

    Joined:
    Jul 23, 2016
    Posts:
    658
    Update: After spending a long time yesterday trying to fix the problem, I gave up.

    I just started a new blank project and imported my player and the room change object and made 2 rooms to see if I still experience the problem upon switching rooms. But it worked normally.

    Then I imported all the assets from the previous buggy game and....it just worked normally. I did not change any code. I have no idea why or how the same assets are working in the new game, but it works and I'm not complaining. I guess I'll never find out what the cause of the error in the previous version was.

    spoonsinbunnies , Catan , TsukaYuriko and Binsk , thanks for trying to help.
     

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