Help with unity

Started by
2 comments, last by Inukai 7 years, 2 months ago
Hello colleagues, I'm new to this area and am having a concert difficulty a bug.
I'm creating a tetris-style game, but I'm having trouble building pieces.
Thus, when the piece collides with the ground it generates a normal piece, but when the piece collides with another piece it generates several other pieces and ends up locking the unity '-'
I'll post some pictures showing the game and the piece of code I made.
Can anybody help me.
Advertisement

Your pictures show blocks that are not exactly aligned with the columns and rows. That leads to various problems.

when the piece collides with another piece it generates several other pieces and ends up locking the unity

I'm not entirely sure what you mean by that.

Some games in the genre have the pieces remain as blocks, if you clear a row and that leaves blocks with a hole below, the blocks will fall if they can.

Some games in the genre, including the original, have the blocks change form into the row. Once it locks in place the four blocks of the tetromino enter an array for the row they're in and they no longer move individually.

Either way, when the entire row is full the row is removed.

but when the piece collides with another piece it generates several other pieces and ends up locking the unity '-'


When Unity locks up it's almost always because you have an infinite loop or infinite recursion in your code. Step through it in a debugger and you should be able to see where it's looping.

Your OnTriggerEnter2D() is called for both pieces at the same time when they collide.

The spawner then spawns two pieces at the same time which instantly collide again and the cycle keeps repeating.

This topic is closed to new replies.

Advertisement