0 votes

I have few scenes in my project. I was able to center all of the other scenes. But i cannot center the main scene in my project. Its fine when it opened on a mobile device(probably because resolution matches i guess). but when i opened it in tablet(its an old tab "xiaomi tab 3") its always align to the right on the screen. I was able to center other scenes but i cant center the main scene to screen for some reason. project setting set as 2D and Expand. I also tried to use Control nod, canves layers, margine containers.. but nothing works. https://i.stack.imgur.com/FJOHl.jpg


Also I tried to add the main scene as a child of one of the scenes that centered correctly. But it still didn't work. So my last guess was, it supposed to something wrong with the camera2d nod .My camera was inside the player scene, so I removed the camera from PLAYER SCENE and added it to the MainSCENE but still it didn't work. Then i delete the camera, surprisingly it work perfectly without problems. So it happens because of the camera..(i have no idea why thought). my scene resolution is 1920x 1080 . but with camera movement it have 1920+320 in the background(when player move on y axis ,bg also moves). I can add offset to camera can correct it in the tab view, but then its wrong on mobile device. So i might need to move scene without a camera i guess

If someone can give any suggestions, Thank you

in Engine by (12 points)

1 Answer

0 votes

Get the viewport display size and half it. Make sure that the scene has the center point in the right position. Then just say position = viewportdisplay.size.x / 2

by (184 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.