r/Unity2D • u/KereMental • 5d ago
Feedback needed Making tetris on unity
On theory, if i am able to distribute folders/parent objects to release the child objects, i can just create the tiles randomly choose one and drop each of them to the field. And then i can discard the parent object to make the tile structure just simple blocks that dont check on collision to every other block except the ones in its own folder and otherwise wait for any input in a second before leaving them and passing to the next one. I would also turn every tile 90 degrees on command and check if all digits in a row are filled before deleting that row and putting the next one in its place. But instead of doing it right after the check it would detect all the filled rows and erase them at the same time because thats what tetris does.
2
u/midge 5d ago
I don’t really follow the approach you’re describing. But if you think it will work, try it out. I made my own version of Tetris years back and it was not bad at all. Good luck with your Tetris!
1
u/MistakeForsaken6653 5d ago
Not sure what I just read but good luck on making your tetris game.
1
u/Ruadhan2300 5d ago
Last time I made a project along these lines I built it data-first and managed it with a state-machine.
Frankly managing the objects in folders sounds like an unnecessary headache, but if it links to how you're writing the code, then do what works.
1
u/TheLayeredMind 1d ago
It's a matter of visual abstraction. If every shape in reality is internally a collection (the composition) of squares, then the Tetris logic becomes a grid of equally sized squares, where each row checks wether every cell is occupied by a square and if so removes it and translates down the settled squares from the top rows down.
Now to Unity:
Tetris shapes while falling could be square tiles of the same color. So a collection of
TetrisUnitprefabs with a SpriteRenderer component. Grouped together under one parent that gives them a shared transform anchor and sets their look so that hey match to build one cohesive shape. As soon as they snap you would just move the children from one parent to the next. This is of course if you build this Editor first. You could of course also make all of it procedurally.But that's the gist of it.