2
我正在嘗試通過計算相應的速度將KinematicBody移動一幀,並將其移動到一幀中。下面是一張僞代碼的描述我在做什麼:在一幀中線性速度與距離的移動
var v = 0;
function update(){
// do update
world.Step(1/60, 10, 10);
// do rendering stuff
// set linear velocity to v
objectBody.SetLinearVelocity(new b2Vec2(0, v));
// reset v to 0
v = 0;
// wait 16.6ms
update();
}
function moveBy(n){
v = n * 60; // set velocity to be n units/sec
}
調用moveBy(300)
實際上並不由300臺移動。它確實向下移動,但距離不是300個單位。
爲什麼這是什麼和可能的解決方案?