Scene transition help


Hey! Long time pixel artist, amateur dev here.

For my first real game I’m working on a platformer. Surprisingly mostly smooth sailing with the help of tutorials but I’m stuck now.

I want my game to have multiple rooms and levels and I’m struggling to transition my player character between them. Obviously change scene does just that, without carrying over any information. I realised that scene variables needed to be changed to global so I can carry money/score over but instance variables like my players health is reset. I’m also un able to work out how to have the player spawn at the correct coordinates (ie. the door that connects to the door from the last scene).

Is there a way to just send one object (my players), instance variables and all to specific coordinates in another scene? Or will I have to set up global variables for the health too? If this is the case, would I have to use global variables to somehow store coordinates for transitioning and if so, how do I go about this?

Sorry for the long winded question, and thank you in advance.

Peace out x


i have not try this yet, but is your player a global object?
if you use variables, like player health as a object variable of your player, they might transition over scenes.

ether way, you have to change your variables to something globally accessible.

as for positioning you store the X/Y positions in global variables and on transition to the next scene
at the beginning of the scene
change player position to global variable X/Y


A tip on how to transition using doorways (or any object) is to add two variables to each doorway instance object called “name” and “destination”. When the player collides with a doorway object (before doing the scene transition) set a global variable called something like “nextDestination” to the value of “destination” on the doorway. Then after you load the new scene, select the doorway object in the new scene that has a “name” that equals “nextDestination” and set the player starting coordinates to the (x,y) position of that doorway object.
This is a data driven model with simple logic, so when you are designing the levels you’ll need to ensure you always put good values on your doorway objects.
I hope this helps.