hello there, i am really fresh on c#(and new here too), and i cant understand how to use these! (i checked the documentation a ton of times)
i actualy understand what they are for, but cant apply. …
i have a float variable that needs to be 0 at some point, but since its an acceleration variable, when the script finishes subtracting, its never Zero, witch is inderstandable, but i cant have a model still moving after a command! thanks in advance!
With Mathf.Approximately you can check if your variable could be 0 without the float imprecision.
If that is true, then do something or dont do something.
Maybe stop substracting and set it to 0.
I cant tell you how to apply this if i dont how you setup your code.
Maybe there is even a better solution to that.
In computer science, the Greek letter epsilon (which looks like ε) is often used to represent “a tiny amount,” or “the smallest amount that matters.”
[It can also be used to represent a set of things that are of interest in a search, but that doesn’t apply here.]
When you have to compare various amounts in floating point numbers, a common way to do that is to say “is it close enough?”
If your mom told you to get a couple dozen eggs, and you came back with 25, that would be close enough if your epsilon was 1. (24 ± 1 includes 25)
In Unity, if you set Mathf.Epsilon to be 1, that means that you’re okay with calling 24 ± 1 good enough. If you set Mathf.Epsilon to be 0.0001, then your tolerance for unequal numbers is 1/10000. 24.0001 or 23.9999 is close enough, but 24.0002 or 23.9998 is not acceptable.
thanks, but as i said, i did understand how it works, but what ai dont know, is the exact placement of the syntax on the code… recently i did used it, and i set the script to return the epsilon value, and it did return “1,4”… very interesting, but can i actually set the Threshold of the epsilon? i mean, a value that ranges from … lets say, 0.01 to 0.01 for instance?