Are there any built-in functions for custom rounding based on multiples? i.e., round to multiples of 0.5?
Jan 25 '12 at 11:55 PM
If you want to round to the nearest 1/x, where x is a positive integer.
float roundedValue = Mathf.Floor(initialValue * x) / x;
Jan 26 '12 at 12:08 AM
Jan 26 '12 at 04:39 AM
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
Once you sign in you will be able to subscribe for any updates here
Answers and Comments
The best place to ask and answer questions about development with Unity. Check out our FAQ for more information.
To help users post good questions and use the site effectively we have posted a tutorial video. Please check it out.
asked: Jan 25 '12 at 11:55 PM
Seen: 829 times
Last Updated: Jan 26 '12 at 04:39 AM
Round to nearest .5?
"bleeding" when using configurable joints
Math.round not work
How can I round a number?
Float to Int
Determinism problems: Mathf, Unity.Random VS Math, System.Random
Making an enemy face the Player
Distance in a Trajectory of a projectile
How do I find the inverse cosine ???
Why does Mathf.Sign(0.0f) return 1?