i am using big numbers, so I use a double variable, and mathf.sqrt does not work with doubles, is there another way?
3 Answers
3Hello there,
This thread might prove a good read for you.
Basically, use Math.Sqrt instead!
Hope that helps!
Cheers,
~LegendBacon
Hey there,
the Mathf.sqrt function is for floats as the Mathf indicates.
Using Math.Sqrt should work for doubles. In case that is not naturally in your script then append a using System; or just write System.Math.Sqrt();
hope this helps! Here is the link for the msdn reference.
Note that Unity's Mathf class is mostly a wrapper of the default .NET System.Math class with additional casting. See the [Sqrt implementation][1]. This is mainly for convenience since our main data type is float [1]: https://github.com/Unity-Technologies/UnityCsReference/blob/master/Runtime/Export/Mathf.cs#L47
– Bunny83thank you so much.
Damn you bacon for beeing faster than me
– Captain_PineappleIt should work as you've written it. Whats the problem now?
– joan_stark