Having issues coding level transitions :(

Discussion in 'Programming' started by Adam Mansour, May 21, 2019.

  1. Adam Mansour

    Adam Mansour Member

    Joined:
    May 14, 2019
    Posts:
    20
    Hey guys!

    I just made a video so you can see for yourself. I hope you can help!



    Thanks in advance!
     
  2. Nocturne

    Nocturne Friendly Tyrant Forum Staff Admin

    Joined:
    Apr 13, 2016
    Posts:
    6,898
    Hi there! Can I suggest you write the issue out and include any code that you think could be causing your problems, or that you need to fix or whatever? Most people here help out in their spare moments and don't have the time to sit through a video, and it also makes it MORE difficult to actually see the issue, not less. You'll get far more replies with a good detailed text post than you will like this.
     
  3. TheSly

    TheSly Member

    Joined:
    Jan 16, 2017
    Posts:
    989
    Part of the problem is you are looking for a tutorial to do an exact thing you are after. As your game gets bigger you will need to work out the solution and code it yourself. Write down what you want, and the steps that will get you there, then try and code it from that solution. For example:

    Problem:
    1. Player needs to move between rooms.
    2. Player needs to be teleported to a particular position at the start of each room, and a particular room.​

    Think how you can solve it
    1. If we make the player persistent we can set his new x and y in the previous room, and he will keep it and be in the correct position in the new room. Sounds good, so make him persistent.
    2. We need to know where to send the player when he touches the edge of the screen. You used a transition object in your testing, enabling you to set where to send him in the new room, and also which room to send him to. Let's use that.
    Inside the transition objects creation code in the room, you can set the target x/y position (target_x and target_y), and which room to send him to (target_room). When the player touches the object, change the room to the target_room and change the players x/y to the target_x and target_y. Having an object at the start/end of the rooms, with different targets, will satisfy the problem.​

    There is nothing too tricky, just try and break it down into smaller steps, and work how to achieve those steps, in order to get the game to do what you want it to.
     
  4. NightFrost

    NightFrost Member

    Joined:
    Jun 24, 2016
    Posts:
    1,959
    So this is basically the same mechanical problem you'd face when creating doors that move the player from one room to another. You need to define a region where room switch kicks off, which is easiest with an instance to collide with. Then you'd need to give each instance information regarding room to switch into and the target coordinates, or create a data structure housing that information. Note that room switch is not immediate, so you cannot position player right after room_goto. You need a mechanism that tells you after the switch where the player needs to be, for example global variables. The positioning itself can be done in room creation code, either move the player (if you like them persistent) or spawn the player.
     
  5. Adam Mansour

    Adam Mansour Member

    Joined:
    May 14, 2019
    Posts:
    20
    Thank you but I learned nothing from this because I did all that.. if you have time I can start a stream and you can watch me do it live.. maybe it works better this way.. I also found out, if I make it persistent, there will always be 2 versions of my character running in every level. Because its the persistent instance and the one I placed there by default in case I need to respawn.. this is so frustrating..
     
    Last edited: May 21, 2019
  6. TheSly

    TheSly Member

    Joined:
    Jan 16, 2017
    Posts:
    989
    When someone gives up their time freely to assist you, this is not really a nice way to reply.

    Guess you were wrong, you learned this.

    So if the player duplicates itself because it starts out in the room, you need to remove it from the room, and find another way to add it at the start of the game. A common way is to have your first room as an initialisation room, with a single object that has create code which creates your persistent objects, then moves to the next room. This way they are only created once, and that room is never run again.
     
    woods likes this.
  7. Adam Mansour

    Adam Mansour Member

    Joined:
    May 14, 2019
    Posts:
    20
    I'm sorry.. it didn't mean to be rude. I was just pissed that day.. anyways thanks for your 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