You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I try to keep consistent speed of bodies on different screen resolutions. Now I test two resolutions:
844x390
1920x1080
I precalculate ScreenHeight and create an object with a mass: screenHeight / 130.0. So the mass is depends on screen height. Then I apply some horizontal force in a 60-fps loop (each iteration) with applyForce(), calculated as: const forceX = screenHeight / 60000. Gravity of the world I set as: screenHeight / 1080.
And I get absolutely different speed on different resolutions. Objects on screen: 844x390 moves 10-20x faster than they move on 1920x1080. Both cases I test on the same device, the same browser, so there's no any problem with different FPS or a performance value.
Why does it happen? How to keep consistent speed? For example, I wanna move my object horizontally by distance: screenHeight * 2.0, spending exactly 1.0 second on different screen resolutions.
I think it should behaive proportionally equals if I set proportionally equal forces, sizes, all those things...
Look I've found the same issue here: #889 but I change the sizes as well so it doesn't look different from one screen size to another to my mind.
UPD:
So, the best approach when working with physics is to use fixed coordinates without using relative values adjusting to current screen resolution? For example, creating a physics world with a size of 1920x1080 and then adjust the graphics to current screen resolution remapping those fixed physics coordinates to current screen resolution each loop step?
But it's very uncomfortable to work when the collider is placed not above the object but in some another place in the world. It's crazy to work with.
Or are there any ways to scale the physics to get the similar behaviour on different scales?
The text was updated successfully, but these errors were encountered:
I try to keep consistent speed of bodies on different screen resolutions. Now I test two resolutions:
I precalculate
ScreenHeight
and create an object with a mass:screenHeight / 130.0
. So the mass is depends on screen height. Then I apply some horizontal force in a 60-fps loop (each iteration) withapplyForce()
, calculated as:const forceX = screenHeight / 60000
. Gravity of the world I set as:screenHeight / 1080
.And I get absolutely different speed on different resolutions. Objects on screen: 844x390 moves 10-20x faster than they move on 1920x1080. Both cases I test on the same device, the same browser, so there's no any problem with different FPS or a performance value.
Why does it happen? How to keep consistent speed? For example, I wanna move my object horizontally by distance:
screenHeight * 2.0
, spending exactly1.0
second on different screen resolutions.I think it should behaive proportionally equals if I set proportionally equal forces, sizes, all those things...
Look I've found the same issue here: #889 but I change the sizes as well so it doesn't look different from one screen size to another to my mind.
UPD:
So, the best approach when working with physics is to use fixed coordinates without using relative values adjusting to current screen resolution? For example, creating a physics world with a size of 1920x1080 and then adjust the graphics to current screen resolution remapping those fixed physics coordinates to current screen resolution each loop step?
But it's very uncomfortable to work when the collider is placed not above the object but in some another place in the world. It's crazy to work with.
Or are there any ways to scale the physics to get the similar behaviour on different scales?
The text was updated successfully, but these errors were encountered: