How to calculate jump height in Unity?

It is sound stupid question! But is there any way to calculate the jump height in Unity.
I asked google for some formulas. But it seem unity does not have enough parameter for it.
Please help!

Hello my friend,

I hope you are doing well. Your question is an interesting one and really depends on how your game is developed. In the classical sense, you can calculate “height” based on instantaneous velocity or acceleration, gravity, and delta time. This is basically a Physics 101 type problem.

But an easy way to do it in code would be to apply a veloicty or acceleration to your rigid body and store the maximum displacement in a public or private variable:

public float maxY;
public float jumpVel;

void Start()
{
   maxY = 0;
}

void FixedUpdate()
{
  if (Input.GetButtonDown("Jump")
      rigidBody.velocity = (rigidBody.velocity.x, jumpVel, rigidBody.velocity.z);
}

void Update()
{
  if (transform.position.y > maxY)
      maxY = transform.position.y;
}

Then you could fine tune your jump velocity, or cap it by setting velocity to 0 if a certain height is breached etc.

Hope this helps a bit & good luck

Cranky Frank