Random Block Generation

I need a way to randomly generate blocks. This is a game where the player is pushed forward at a constant speed and they move left and right to avoid obstacles. For my game, when the player hits an obstacle, I reload the Scene. This causes the scoreboard to reset too. So I need to be able to randomly generate blocks so I can simply send the player to the start, destroy all blocks and replace them randomly. This is also just a cool feature to have If the blocks are generated randomly. All I need is a way in C# to generate the blocks. I know that I will need thinks like offset of blocks and spaces between each row.

Thanks All!

on your main blockGenerator / game script…
have a variable to store your block prefab… or an array, list or dictionary of prefab blocks…
public GameObject MyBlock;
maybe a couple more variables, for min and max X position at which to generate the block.
to keep it simple use a unity cube which is unit size 1 when its scale is 1. then you can spawn them at 1 unit apart each.
make a GenerateBlock() function… add whatever parameters you want, like maybe world z,y,position, of you block is randomized in X, maybe block index or key string, if its in a list or dictionary of blocks.
super simple version…
public GameObject GenBlock(Vector3 worldPosition)
{
//randomize position of block
worldPosition.x = (int)Random.Range(-max, max);

//create the object and return it
return GameObject.instantiate(MyBlock, pos);
}

Thanks! I tried generating just one block using this and I eventually did get it to work. It will probably be a struggle to get the perfect offset etc. for each one though!