Sometimes the ray is not intersecting the plane when getting the z position. Quick fix to return 0 for the getZFromPosition function if that happens.