Just going to link the post about how to use code tags: Using code tags properly
Nonetheless, I can see you’re doing physics stuff in Update()
, when physics should only be done in FixedUpdate()
. This is most likely why you’re getting slightly varying jump heights, as multiple regular frames (Update) happen before the next physics update (FixedUpdate), applying slightly different amounts of force each time.
In general, you should poll input in Update, and act upon it in FixedUpdate should you need to effect physics.
I’ll also note you should not be mixing up regular translation and physics. You should only do one or the other, as you’ll get undesirable results usually.