Randomly Generated 2D Level

So what I want to do is make a Procedural Random 2D game, with different levels every time the player dies.

I already have the game mechanics, and I could make my own level if I wanted to, but how would I go about making the level change after every respawn.

Here’s a few images to show an example with 2-3 blocks of what the random script would do everytime I die, so you have a better idea of what I’m trying to achieve.

alt text

So what I want is the level to add/subtract blocks. Make them bigger or smaller(x scale only)

and also change their position with some limits.

They can only be so much units away from another block, or it will mess up (X and Y both or horizontally and verticcally)

So I know I need to probably do a lot of scripting with distance, and random numbers, but to be frank, I don’t know where to start.

Also if you have any questions, please ask.

Thank you :slight_smile:

For randomness use Random.Range()

To make random spaces, well i used something similar by instantiating objects relative to the previous objects. for example:

var lastObjPos : Vector3;
var obst : Transform;

lastObstPos = ((lastObstPos.x + Random.Range()),(lastObstPos.y + Random.Range());