How do I remove the decimals from my script so that my text mesh doesn’t show something like 20.62634325 meters?
var Other : Transform;
function Start () {
}
function Update () {
transform.localRotation = Other.localRotation;
}
How do I remove the decimals from my script so that my text mesh doesn’t show something like 20.62634325 meters?
var Other : Transform;
function Start () {
}
function Update () {
transform.localRotation = Other.localRotation;
}
ToString() can be overloaded:
float fl = 0.1234567f;
print(fl.ToString("0.00")); // prints 0.12
Well there’s absolutely no reference to anything in that code you posted, so not sure how that’s supposed to help.
There are a couple easy ways to drop the extra digits:
displayValue:int = Mathf.RoundToInt(floatValue);
or
displayValue:int = (int)floatValue;
Multiply by 100, convert to an int, then convert back to a float and divide by 100, that will give you just 2 decimal places.