[SOLVED] : Explicit match on x and y velocities of a rigid body and jump function

Just so you realize that’s an extremely small amount… 0.0001 to be exact.

This means it is possible to be going UP faster than this and in a single frame be going DOWN faster than this if gravity is “strong enough,” in which case it will not trip.

Back-of-envelope checks tell me that earth’s gravity at -9.8 m/s^2 at even 120fps (which is high!) is WAY strong enough to miss this tiny micro window, like nearly three orders of magnitude too large. You will be extremely unlikely to ever detect y velocity less than that tiny amount unless you just get lucky.

9225939--1288395--Screen Shot 2023-08-15 at 9.25.29 PM.png

Instead, every frame, compare if its sign changed in the direction you wanted compared to the previous frame.

Floating (float) point imprecision:

Never test floating point (float) quantities for equality / inequality. Here’s why:

https://starmanta.gitbooks.io/unitytipsredux/content/floating-point.html

https://discussions.unity.com/t/851400/4

https://discussions.unity.com/t/843503/4

“Think of [floating point] as JPEG of numbers.” - orionsyndrome on the Unity3D Forums