How do I calculate velocity in my physics-based game when a character jumps?

Calculating Jump Velocity

Formula

To calculate the jump velocity of a character in a physics-based game, you can use the following formula:

Velocity (v) = sqrt(2 * g * h)

Where:

  • g - Acceleration due to gravity (approximately 9.81 m/s² on Earth).
  • h - Maximum height the character can jump.

Example Implementation

float CalculateJumpVelocity(float height) {
const float gravity = 9.81f;
return sqrt(2 * gravity * height);
}

Useful Resources