Should I calculate in meters or pixels
In my car sim I am doing my calculations in Standard Units, except for the distance which is in pixels. Is this still correct (my guess is no) or should I use Meters ? If I should use meters what is the best way to go about it? should I just pick a scale 10px = 1m or is there a better way to do this ? thanks in advance. Some additional info: I'm using Unity3D and using its physics engine.
A lot of physics engines operate at a scale of 1 unit = 1 meter.
Unity isn’t any different, as you can see in the manual.
The size of the your GameObject’s mesh is much more important than the mass of the Rigidbody. If you find that your Rigidbody is not behaving exactly how you expect – it moves slowly, floats, or doesn’t collide correctly – consider adjusting the scale of your mesh asset. Unity’s default unit scale is 1 unit = 1 meter, so the scale of your imported mesh is maintained, and applied to physics calculations. For example, a crumbling skyscraper is going to fall apart very differently than a tower made of toy blocks, so objects of different sizes should be modeled to accurate scale.
So 1 unit = 1 meter. Don’t use pixels for your physic engine. Your world should be decoupled from the actual rendering output (which is in pixels)
For the best simulation accuracy, you should choose units such that typical numbers are close to 1 in scale; this will ensure your physics’ floating-point computations are as accurate as possible. This applies to all numbers — lengths, masses, etc.
So, for games with human-scale objects like cars, 1 = 1 meter is a perfectly fine choice. On the other hand, if you were, for example, simulating a pinball machine, it would be good to scale things so that the ball’s radius is 1.
- Database Administration Tutorials
- Programming Tutorials & IT News
- Linux & DevOps World
- Entertainment & General News
- Games & eSport