1. Hey! Guest! The 33rd GMC Jam will take place between May 23rd, 12:00 UTC (Friday noon) and May 27th, 12:00 UTC (Monday noon). Why not join in! Click here to find out more!
    Dismiss Notice

GMS 2 [SOLVED] Warp between rooms problem

Discussion in 'Programming' started by Sqoler, May 7, 2019.

  1. Sqoler

    Sqoler Member

    Joined:
    Apr 16, 2019
    Posts:
    10
    Hi.

    I am new to GMS2, and while trying to add a warp to my game, it does not work. When I go into the warp object I made, I do teleport to the second room with my character, but I teleport under the other object I have. Take my grass for example. The grass layer is above the player layer. Any way to fix this?
     
  2. Nocturne

    Nocturne Friendly Tyrant Forum Staff Admin

    Joined:
    Apr 13, 2016
    Posts:
    6,497
    Is the player object persistent? If so then this is partly because of a bug (which will be fixed in the next update), but the fix is really easy... Simply add a "Room Start" event with code to assign the instance of the player object to the correct layer, like this:

    Code:
    /// ROOM START EVENT
    layer = layer_get_id("Main_Instances"); // Use the name of the layer you want to assign the instance to
    :)
     
    Last edited: May 7, 2019
  3. Sqoler

    Sqoler Member

    Joined:
    Apr 16, 2019
    Posts:
    10
    It gives me this error when I add that code:
    Object: objplayer Event: Room Start at line 5 : unknown function or script _id
     
  4. Nocturne

    Nocturne Friendly Tyrant Forum Staff Admin

    Joined:
    Apr 13, 2016
    Posts:
    6,497
    That's a typo! Fixed the original code... :)
     
  5. Sqoler

    Sqoler Member

    Joined:
    Apr 16, 2019
    Posts:
    10
    It worked! Thanks a lot!
     

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