Hi again. Sorry for making kind of a duplicate topic, but the one I created 20 days ago really didn’t get much attention and hasn’t helped me. I’ll probably delete it later.
I’m making a topdown-rpg. Almost all of my layers are zoomed 6x. It works wonderfully. But I have some specific objects that are zoomed more or less than 6x and that’s when problems show up.
For example, in my sewer scene, I have a 12x zoomed image of a brain pretty much in the middle of the screen - at least that’s where it shows up if I preview the project from the sewer scene. But if I leave the sewer and come back (or preview the project starting from some other scene), the brain is nowhere to be seen. I can tell from the debugger that it still has the exact same coordinates and other properties as below, but it doesn’t show up.
Make sure the camera for the layer that the brain image is on is centered on the brain, or in a position near the brain so the brain image is within the screen confines.
Currently it’s not centered.
I don’t understand why I would need to do that since the brain does show up even without it. It’s just that after I change the scene and come back, it disappears.
Thanks for the fix suggestion, but I’d really like to understand what’s going on so I can come up with different solutions myself when I need to.
Are you pausing the scene and then resuming it? If so, are there any events for when the scene resumes? Or are there any global variables that affect the camera or brain object positions?
No, I don’t pause the scene.
No, there are no global variables like that. Keep in mind that the actual position doesn’t change according to the debugger. It only appears to change.
Yes, which points to the layer camera resetting to another position. You can confirm the camera position in the debugger too (click on the scene name and the scene layer details will be displayed). Do this before you exit the scene, and then again when you go into the scene again.
Thank you. I didn’t realize I can see the camera positions in the debugger, thanks.
You are right. This is what the debugger says right after I preview the sewer scene.
This is what is says after I leave and come back.
I still don’t get what could be causing this though…
It’s because you are reloading the scene, rather than pausing and then returning. As a result, the camera defaults to the position so 0,0 is in the top left of the screen. All objects and positions are reset when a scene is loaded.
If you stay with the open new scene action, then I’d suggest you use global variables to store the camera position just before you exit the sewer scene (remember to set it to 960, 540 when you create the variables in the editor). Additionally, create an event in the sewer scene with condition "At the beginning of the scene" and actions that position the BrainGame layer camera using the global variables.
I’ll try that.
Still - I don’t understand how this is happening? When I load the scene it should load the same way every time right? If I need the global variables to place the layer on the right spot, how does it NOT need it the first time I load the scene (when I first press preview)?
So it focuses on the brain object the first time you load the scene? Then I’m not sure on that one. I’d have to play the game or even see the project to work out what’s happening.
Well it focuses on the brain object the first time I load the scene IF the scene in question is the first one to be loaded (I start the preview from the said scene). If I start the preview from some other screen and go to the sewer scene, the brain NEVER shows up.
GDevelop should be starting up a scene the same way every time if the scene is opened up, either as first scene or with the change scene action, and there is no explicit camera repositioning.
The only time it could change is if the scene was paused and then resumed. Then the camera will be wherever it was positioned when the scene was paused.
Here’s my project. Tell me if the link or something else is messed up. Hopefully you can find out what’s going on.
The brain doesn’t show up UNLESS I start the preview from scene 1 and even then it only shows up once.
I can’t see why it’s happening, and it seems like a bug with GDevelop. I’d suggest you create a new post under Gdevelop Bug reports, including the link to the test project.