- Home /
More precise Vector3
Hey guys... I made a bullet gravity and wind effect with raycast... but the Vector3 use just 1 case before 0, giving a squared result... My script is working fine, but i need more Precise Vector3.... E.G. the unity is doing this:
100/27 = 3.7
but i need a more precise value:
100/27 = 3.7037 (more approximated value)
how can i "change" the Vector3 accuracy?
Answer by Eric5h5 · Apr 13, 2011 at 11:05 PM
Vector3 uses 3 single-precision floats, which can't be changed. Presumably you're looking at the output from Debug.Log(myVector3Variable), which is truncated for readability. If you want the "real" thing, print out x, y, and z separately.
yea you are right, the vector3 is precise, my problem should be an other... thanks!
Answer by JoeStrout · Oct 05, 2011 at 09:39 PM
No, you don't have to print out x, y, and z separately. There is an overload of Vector3.ToString that takes a "format" parameter. This is a C# Standard Numeric Format String. So, for example, to print your vector with 4 digits after the decimal place, just use
someVec.ToString("F4").