[Solved] Player position when switching rooms with global variable?

OK thank you.
Do you have to enter the two variables for each scene?

The variables are global and are available in all of your scenes once you have declared them.

Hi here are some screenshots but the player can’t pass the third scene

In your event, the first line in the actions is to change the scene. The following two lines, where you get the position of the player, are then not executed anymore. In Gdevelop the actions are performed always from top to bottom. So you need to get first the x- and y-position and then change the scene (all in the same event block).

I’m new and I don’t know how to use these variables, there aren’t any examples and videos about it

Alright, so did you manage make it work? It should look something like:

And that’s what you can do in your next scene:

Yes it works I have to fix a few things like for example the size of the character to the next scene.
Thank you

1 Like

Another question now when the character passes to the next scene it appears with the original dimensions like 610 x 523 I had resized it to the second scene 116 x 104 :grin:

Okay, what is your problem. If it is about the position, you could divide the x- and y-position by the scale-ratio from one scene to the other. You can also scale the player-sprite if necessary.

At the moment your ratio is a bit strange 610 / 116 = 5.258620689… I would recommend to choose something that scales better. If you have pixel art you need to consider the scaling ratio well to avoid pixel distortions.

My player from the first second scene resized it with width from 610 to 116 and height from 523 to 104 when I change scene the player size returns again to 610 width and 523 height

:woozy_face:

Could you post your events?


the dimensions of the character of the second scene must be identical also in the third scene and so on

I see. In this case you have to scale the player sprite for every scene individually to the size you actually need, or alternatively you could have different sprite-object sizes for each scene. I know this is quite tedious but your sprite-object is not automatically adjusting to a different scene size.

Ok how can I resize it for each scene individually because from the second to the third scene with create object the player regains the original dimensions

For each scene you have to do something like this (with the relative values for each scene):

Ok perfect thanks again you’re a friend

1 Like

hey im having the same problem i tried to do what y’all said but still it wont work when entering like a house or a shop everything i okay but when i went out to go to the main scene here where is the problem my player just return back to his original
X and Y cordinates with everything that he collected back again plz i need your help its been 2 days and im still stuck in this if u want i can give my discord id so any one can help plz
an thank you <3

Hi, could you post your events and explain what exactly should happen? You enter a room, get out of there to the main scene and then you want to be where?




i want the player when exiting the store to respawn near that balck dot but he respawn in his first x and y cords

This thread might be helpful:

Check the responses of krunkster and jack!

Basically, you need to set up a system that makes it clear at the beginning of the scene whether you came through the door or some other entrance. You need to use global variables for that. The more scenes and doors/entrances you have, the more complex it will be.

There is another, maybe easier solution that you can find here: