Any difference between using 0.1 and 0 for my conditions in my animator transitions?

I noticed that in most Unity tutorials, they use transitions with conditions such as “Less than 0.1” or “More than 0.1”. Why is that? Wouldn’t 0 be preferable? Or is it to make the transitions seem less stiff/robotic?

Sorry if it’s a stupid question.

Well in real life maths any number can be memorized exactly. But the computer can’t do this. It only has finit memory to save a number. The computer has two basic types of numbers it can save: integers and floats.

Integers are numbers {…, -1, 0, 1, 2, …}. Integers are exact thus you can compare them with an equal sign ( == ). But due to the limited memory there is a maximum which the integer can’t exeed. This means a 16 bit integer can actually be out of this set: {-32.768, …, +32.767}

Floats on the other hand are numbers like 1.234567E+20. The computer saves the first couple of numbers (7 for the 32 bit float) and an exponent. The biggest (ignoring the sign) float possible is 1.79E+308 and the smallest is 1E-44. A far bigger range than the integer. The downside is, that floats are not exact. You usually have a hard time comparing two floats with the == operator. Instead check if the difference between two floats is close to zero.

Enough with the general talk. Back to your question. If you want to, lets say, animate a person. You have a running animation and an idle animation. Of course you want the running animation to play if the character runs and the idle animation otherwise. If you would check velocity.magnitude == 0 as condition, then the running animation would be played even if velocity.magnitude would be 2.463E-7. The character would run happily on the spot. Not good.

Short answer: Getting a float to an exact value is not always possible. You should never use == to compare a float since floats are not exact and this could lead to unwanted effects (see the example above). To compare to floats, sustract them and see if the result is small / close to zero.