Create Global PixelsPerMeter setting and change force units to Newtons. #7037
zitongcharliedeng
started this conversation in
2D
Replies: 2 comments 14 replies
-
What are you basing this on? The only thing that seems to represent this (indirectly) is that gravity defaults to 980, but you can just change that, is there any other place where there's this definition of units in physics or otherwise? What is the usefulness of defining a meter for 2D in the engine? |
Beta Was this translation helpful? Give feedback.
8 replies
-
Make a constant, put it on a script with a class name, something like this:
And then define your forces like this:
|
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The engine has arbitrarily locked 1 meter = 100px.Having the default force unit as kg*px/s^2 instead of Newtons is a pain to work with.
Physics code would be more intuitive if we used consistent SI units (like having gravity in m/s^2), and added a single PixelsPerMeter variable e.g. in editor settings, like in Unity, for 2D worlds.
The lack of this "scale variable" I am proposing also makes it harder to do things such as increasing the resolution of the textures in your game (e.g. 32x32 texture pack into 64x64), you'd have to change all your force values and gravity values to compensate, which would be much easier with a single PixelPerMeter setting.
Please end my suffering.
Although, I haven't been using the engine for very long. Maybe someone could enlighten me on a workaround/ correct my misunderstandings?
Beta Was this translation helpful? Give feedback.
All reactions