In the case of free fall movement, the change value of moving distance in the same time interval cannot be greater than 2, that is to say, it will change from free fall movement to uniform linear movement
oxDesigner opened this issue · comments
In the case of free fall movement, the change value of moving distance in the same time interval cannot be greater than 2, that is to say, it will change from free fall movement to uniform linear movement
I want to know how to modify it
code:
const bodyDef = new b2BodyDef;
bodyDef.type = b2_dynamicBody;
bodyDef.position.Set(0, 4);
this.body = world.CreateBody(bodyDef);
const dynamicBox = new b2PolygonShape();
dynamicBox.SetAsBoxXY(0.1, 0.1);
var lastX = this.body.GetPosition().y;
setInterval(() => {
var X = this.body.GetPosition().y;
console.log(X - lastX);
lastX = X;
}, 1000 / 60)
const fixtureDef = new b2FixtureDef;
fixtureDef.shape = dynamicBox;
fixtureDef.density = 1;
fixtureDef.friction = 0.2;
this.body.CreateFixtureFromDef(fixtureDef);