ScreenWidth() not correct on Android

Hi, I have a strange problem: if I allign objects in the center of the screen using ScreenWidth()/2, on Android the aligment is not correct (on my PC all is fine).

My game resolution is: 720 x 1608

Device orientation: Portrait

Game resolution resize mode: No changes to the game size

I tried to show the ScreenWidth using “Change the BBCode of text set to ToString(ScreenWidth())”: on my PC the value is 722 (why? Shouldn’t it be 720?), on my phone is 360.

I tried to activate full screen or to change the game size from properties, but it doesn’t work.
This game hasn’t a Camera, the screen is blocked.

Thanks in advance!

PC: all is fine

Android: resolution is not correct

1 Like

Hi there

Maybe this old post can help you find a solution?

I have yet to mess a lot with screen width on android so I can’t really give a good solution.

Maybe someone else can help

Hi, thanks for the reply.

The resolution on Android is perfect, only the value of ScreenWidth() is not correct.

I don’t understand why on PC I can center objects using ScreenWidth()/2 and why on Android this value is halved.

Is it a bug?

1 Like

1- I tried all your settings, and it’s working perfectly, as you can see.
2- have you tried using (scene width) expression ? I think that’s the one you need, not the screen width (screen width is the actual device screen width not the scene which is 720)

1 Like

Hi, thank you so much!!!

You are right: using SceneWindowWidth() all works fine!!! :smiley:

Really thanks!!! :hugs:


Throw a link to your game once you are done! Would love to try it

1 Like