• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Having issues coding level transitions :(

A

Adam Mansour

Guest
Hey guys!

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


Thanks in advance!
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
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.
 

Slyddar

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

NightFrost

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

Adam Mansour

Guest
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.
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 by a moderator:

Slyddar

Member
Thank you but I learned nothing from this because I did all that
When someone gives up their time freely to assist you, this is not really a nice way to reply.

I also found out, if I make it persistent, there will always be 2 versions of my character running in every level.
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.
 
A

Adam Mansour

Guest
When someone gives up their time freely to assist you, this is not really a nice way to reply.
I'm sorry.. it didn't mean to be rude. I was just pissed that day.. anyways thanks for your help.
 
Top