Download

Obstacless Spawning too close to each other

I am creating a mobile endless runner game and I am trying to spawn obstacles randomly but sometimes they spawn too close to each other. I want that Obstacles spawn after a certain distance from each other.
Here’s whats exactly happening: There are infinite tiles generating and size of each tile is small and I want that the obstacle spawn at a distance of at least five tiles from previous one. I cannot increase the size of tiles as it will rune the look of game.
I have uploaded picture of code that I am currently using.