- Home /
Gravity speed slows down when increasing screen size
Hello guys! I'm working on 2D mobile game and my player is falling slower when i increase screen size in unity editor, also same thing happens on different sized phones - bigger phone screen size, slower falling speed. why is this happening?
Answer by toromano · Apr 25, 2016 at 01:00 PM
You need a screen independent gravity. Gravity doesn't change actually. what changes is the height when your screen gets taller. You need something like:
float designScreenHeight = 960f; // design screen height. change this to your value
void OnAwake()
{
Physics2D.gravity = new Vector2(0, -9.8.0f) * Screen.height / designScreenHeight;
}
Hope that is helpful.
Your answer
Follow this Question
Related Questions
Change GravityScale in runtime 2 Answers
How can you make gravity to not have any acceleration but with const velocity? 1 Answer
Change a specific Gameobjects rigidbody gravity to horizontal (left) 1 Answer
Simple question about unity 5 rigidbody/gravity 1 Answer
My player is unexplainably destroyed when collides with a collider 0 Answers