Saturday, April 9, 2011

9


Problem: Box2D was horribly limiting the maximum speed of objects, and colliding objects together was displaying odd behavior. The fire hose we were trying to create could launch water out at a trickle at best, and it was impossible to knock the block we had created with this water anyways. This was the case no matter how high we set the water’s initial velocity; it went the same speed at a velocity of 5 as it did at a velocity of 5000. Objects would also fall incredibly slowly. 

Impact:  Knocking over a house was impossible with this in place, and since the player’s running speed was just as fast as the water of his hose the game looked bizarre and stupid.

Solution: We were drawing the game to be exactly the same size as the object in box2D, unaware of the scale Box2d actually used. As far as the physics engine was concerned, all our objects were the size of a small continent and reaching terminal velocity long before reaching the improbably huge velocities we were assigning them. By scaling down every number given to the physics engine by 100 and scaling it back up before drawing it to the screen, the problem was fixed and all objects behaved normally.

No comments:

Post a Comment