Floating point precision and random generated content
So i am trying to generate a random tunnel for my 2d game, i have parts of the tunnel that are exactly 1in width and im trying to spawn about 30 of them in a line.
Most of the parts are exactly where they should be, 1 coordinate apart. And there are no space between them. But about 1or 2 of them are are off by around 0.05 coordinates, which creates a rather disturbing space.
First i tried computing the coordinates, starting with a fixed point and then adding one for each additional spawn. Then i tried to make myself 30 placeholder objects that are on the exact spots where the parts should be, and then spawning the parts on them.
But both methods create the same amount of mistakes. I think the problem is in floating points, but the size of the error makes me a little bit unsure.