Hi new to box2d, I am having trouble with the size of units and how the box2d to pixels conversion should work. I have a couple of balls with box2d radius of 7. It´s all pretty absract so I don´t care if it´s correct world units but I currently have a gravity of -200... Otehrwise it´s like falling in sirap. The window is 800x600 and sprites are around 24x24. Positioning and all stuff works but it´s just the units that are really large.
Problem with units
General DiscussionUnits matter because Box2D is tuned to work within a specific range, from 0.1 meter to 10 meter. Different values work, but they cause weird behaviours like your syrup falling and huge gravity.
Your balls are actually house-sized balls. When you let them fall, they fall slowly because they must be at (I'm guessing) 100-200 meters above ground. Drop a house from a skyscraper on Earth and that's what you get. Increasing gravity works, but you will hit the speed limit of 200m/sec rapidly which will cause other problems.
Converting units from physics to screen space isn't hard. You only need to multiply every position by a constant factor. If you want a 1 meter ball to be displayed as a 24 pixel ball, then take its position and multiply by 24 and you have the correct position in screen space.
Your balls are actually house-sized balls. When you let them fall, they fall slowly because they must be at (I'm guessing) 100-200 meters above ground. Drop a house from a skyscraper on Earth and that's what you get. Increasing gravity works, but you will hit the speed limit of 200m/sec rapidly which will cause other problems.
Converting units from physics to screen space isn't hard. You only need to multiply every position by a constant factor. If you want a 1 meter ball to be displayed as a 24 pixel ball, then take its position and multiply by 24 and you have the correct position in screen space.
I have everything working as it is now with big units. Will I run into any trouble with this? All seems to work fine. I increased the max linear velocity in the settings to 300.
Original thread: https://box2d.org/forum/viewtopic.php?t=3941