RayCast Hit Point rounding itself...?

I’ve written a voxel system that smooths the top of a cubes four vertices rather than just maxing them to their corners. this is based on simplexnoise so sometimes a value is only 0.0001 above the integer or below, etc.

90% is working nicely at this point. I’m running waves of debugs on this code since last night and I’ve found that my raycast hit.point is only sending numbers to the tenth (1.1, 1.2) for collision math with makes my 15.95 turn into a 16, so it thinks I’ve hit an empty cube, when I really hit the 15.

here is the debug:

cube: (3.0, 16.0, 2.0)
hit: (3.9, 16.0, 2.5)
height: 15.95

I could just round everything to the tenth, but… can hit.point not go anymore specific than this? Is this a setting somewhere?

Thank you.

Only the debug is rounded, the actual value is not. For instance, use a public variable to receive the hit point and you will see some more accurate values.

public override string ToString ()
{
    return UnityString.Format ("({0:F1}, {1:F1}, {2:F1})", new object[]{
          this.x,
          this.y,
          this.z
     });
}

This is the ToString used by default in debug for Vector3. It only prints one decimal. If you want to see more accurate values use your own Debug:

Vector3 v = hit.point;
Debug.Log(v.x+", "+v.y+", "+v.z);

this should print out more accurate values.