Best way to handle random spawning of objects in an area?

Hi, trying to figure out how to spawn objects within an area, move towards the player and then destroy them. The objects need to have varying width’s/heights and depths.

Example image below. The blue objects are what are going to be spawning and moving. Red cube is the player.

I’m also not sure if its best to randomly generate blocks or create presets off-camera and move their position

Any help would be appreciated, thanks

Last question first: I would go for presets. That’s the easiest way to ensure your game is solvable (I guess the player has to avoid the blue blocks).

Therefore I would track the position of the farest prefab-clone and create the next one as soon as there is enough space for the next one.

1 Like