- Home /
Question by
VahanSardaryan · Jan 13, 2019 at 06:05 PM ·
screen resolutionscreen sizescreen.widthscreen.height
how can i divide screen to x & y axes for different resolutions
When I set a touch position for different phones it works differently.I want to divide the screen.So when player touches the left side of the screen do something,and when touches the right side do somethng.
Comment
Best Answer
Answer by sh_code · Jan 13, 2019 at 08:38 PM
My psychic debugging powers are telling me you are hardcoding the number in your condition.
Touch.position.x < Screen.width / 2
is touch on the left half of the screen
Touch.position.x > Screen.width / 2
is touch on the right half of the screen.
Main lesson: don't hardcode numbers for what you know is different between devices.
Sorry for my English and thank you for helping me.