Re: Calculating relistic falling dammage?
if (this._onGround_ == false) this.v.y -= 9.8 * dt;
else if (this.v.y < -9.8*dt)
{ // This is when you hit the ground after falling.
falldamage = this.v.y * fallfactor;
// landsounds, etc
this.v.y = 0; // assuming you don't want to bounce.
}
I tend to like values between 5 and 7 for v.y when jumping, but the important thing to remember is that whatever v.y is at the start of a jump, it will be negative that when landing. So you should avoid falldamage for any value of v.y greater than minus jumpspeed, at least.
And dt is how much time each frame covers. If you're using timers, this will be time.elapsed * 0.001. If you're using fixed frame lengths, it's whatever that is.
-- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector