これらの式のジャンプサイズは、1秒あたりの更新量が少なくなるにつれて小さくなります。重力とジャンプ速度の力が減少する量を乗算するデルタ値、および反復ごとにデルタが加算される経過時間(デルタ値は最後の更新から経過したミリ秒の量)を使用すると、正常に機能すると思います。
//d is delta
...
if(isFalling||isJumping){
elapsedTime +=d;
//the elapsed time is the total amount of time passed since one started jumping,
//so that's logical to add the amount of time since last update.
long tesquared = (long) Math.pow(elapsedTime, 2);
//amount of time elapsed squared.
jumpSpeed+=-0.0000005*elapsedTime*d;
//this is the amount that jumpspeed is taken down by every time.
if(jumpSpeed > 0){
isJumping = true;
} else {
isJumping = false;
}
double fGravity = 0.0000001*tesquared*d;
// this is the equation for gravity, the amount that the player goes down
yRend += jumpSpeed - fGravity;
//the amount it goes up, minus the amount it goes down.
xRend -= strafeSpeed;
oldyRend = yRend;
}
ジャンプを開始するには、jumpSpeedを任意の量だけ追加します。
問題は、1秒あたりの更新量が減少すると、ジャンプの持続時間とマグニチュードが減少することです。ここでのデルタ値は問題ないと確信しています。つまり、問題は方程式自体にあるはずです。
デルタが大きいほど、それはより速くfGravity
オーバーランしていると思います。jumpSpeed
だから私の質問。問題が本当に方程式自体にある場合、プレーヤーの上向きの力から下向きの重力を引いたものをモデル化する正しい方法は何ですか?
jumpSpeed+=-0.0000005*elapsedTime*d;
と
double fGravity = 0.0000001*tesquared*d;
?
問題がデルタ値が正しく適用されていないことにある場合、それを適用する正しい方法は何でしょうか?