- Home /
Convert float to int without Math.Round?
It appears that System.Math.Round does not work on the iPad! I need to convert some floats to int. Is there another way to do this in Unity Script?
Can you not cast it? Like... someFloat = (int) anotherFloat;? Sorry, I don't know if you can or not... Just a suggestion.
Answer by Peter G · Feb 20, 2011 at 05:55 PM
Not sure whats wrong with casting. On js, though, I believe you must use the as
syntax:
var myInt : int = myFloat as int;
Just what I needed, thanks guys! $$anonymous$$uch simpler than C++ way. LOL.
Answer by Ben · Jan 19, 2011 at 12:21 AM
Never mind. System.Math does work. There was some related code that worked fine on the Mac but not the iPad. I blamed the wrong line!
Your answer
Follow this Question
Related Questions
Javascript int to float 1 Answer
float = int / int float value always 0 1 Answer
Having a GUI text as a int 3 Answers
"Talent Tree" global yes/false var and int? 3 Answers
Float to Int 4 Answers