Jump to content
  • Advertisement
Sign in to follow this  
Camila Marques

Unity Help with unity

This topic is 594 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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. 

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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. Edited by Nypyren

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!