Game Development Reference
In-Depth Information
And the output window confirms what we've seen:
Sphere 0:410
Sphere 1:80
Sphere 2:80
Middle and right spheres now react in the same way, while the left sphere still
remains in its position.
What's wrong with it? It's a matter of time. While an impulse is applied in a single
instant, a force needs to be applied over time, which dealing with physics is normally
measured in seconds. This means if we want the left sphere to react like its sisters,
we should multiply middle sphere force by the amount of steps required to generate
a second of simulation.
Applying a force to get a linear velocity
As the Step method works with a time step of 1/30 seconds, we need to multiply
the force by 30 , so let's change the Main function in the following way:
public function Main() {
world=new b2World(new b2Vec2(0,10),true);
debugDraw();
floor();
sphereVector=new Vector.<b2Body>();
for (var i:int=0; i<3; i++) {
 
Search WWH ::




Custom Search