magnetization of comma sized cubes

For rounding of number to arbitrary grid size using something like this:

x = Mathf.Round(x / 1.5f)*1.5f;

I leave it as basic exercise to replace 1.5 with whatever your grid size is and applying to each coordinate dimension.

Alternatively you could use the Unity Grid class for converting between grid and world coordinates.

2 Likes