It strange and fantastic how small changes can drastically change the behaviour and performance of code.
I was experimenting with some parameters in box2D, because I though the tank was behaving wierdly with the tracks jittering about in a non estetical fashion. It didn't get it any better. I also tried fixing so that the tank would stand still when you didn't press anything by adding revolve joint friction to the wheels. This worked but caused more jitteriness -> not good!
So after some increasingly vigorous headbanging against the virtual brick wall of box2D's inner workings, I resorted to the world wide manual - google. Meaning I quickly ended up browsing the box2D forums in search of an answer. Of course I didn't find anything, but I kept coming across discussions about wether to insert the pixel units directly into box2D or to transform them into the scale 0.1-10, which is where at least the c++ version is optimised.
Grasping at straws I asked if this was necessary, and got the answer that "yes, definitly recommended". So I did, which means adding a lot of " / PHYS_SCALE" and " * PHYS_SCALE" everywhere in my code. But whoa! Result:
- No jittering. Only some oscillation when standing still.
- Almost DOUBLED performance! Check the physics fps! Now that's awesome.
So go ahead and feel the difference!
Recent comments
4 weeks 12 hours ago
4 weeks 4 days ago
11 weeks 2 days ago
11 weeks 2 days ago
12 weeks 1 day ago
12 weeks 4 days ago
12 weeks 4 days ago
13 weeks 2 days ago
14 weeks 6 days ago
15 weeks 2 hours ago