Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Scumble373 · Feb 27, 2014 at 09:58 PM · collidertriggersendmessageadding

Tetris style math game problem...

Hello everyone,

I am trying to create a tetris style puzzle game with math. Basically, blocks with numbers on them will fall, and as they collide (or trigger) with each other they will add that blocks value to their own, and vice versa. I am having an EXTREMELY difficult time doing so. All blocks have a raycast on the left and right side that can tell when a block is on the right or left side, I also set up a trigger box that extends out past the box to check when a box is triggering with it.

How can I go about creating this system? Is there an easy way?

Right now, when a block collides with another block the current block changes but the previous block stays the same. I need a way to stack blocks where once a block touched another block, they both become the same value: (first block value + current block value) and then apply that to the rest of the boxes that are touching it.

That might be really confusing.... any tips?

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Jamora · Feb 27, 2014 at 10:01 PM 0
Share

The chances of you getting help would increase noticeably if you posted the code you have currently.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by haim96 · Feb 27, 2014 at 10:25 PM

if you asking me, you are doing it wrong. i think that tetris game should be managed by array that will handle the block position and type. you need to update the array with new positions and block types in every move cycle and check what ever you need to check.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Scumble373 · Mar 03, 2014 at 05:10 PM

Thanks man, that really got me on the right track. I started using an array like you said, and after many many hours of work I finally got the addition system working flawlessly. Here is the function I ended up using, in case anyone else if having a similar issue.

 int addUp(int[,] array5, int xPos, int yPos)
     {
 
         int finalVal = 0;
         //print(xPos);
         //print(yPos);
         //int j = 0;
         bool allZerosR = false, allZerosL = false;
 
         //is red block at bottom?
         if (yPos != 19)
         {
             for (int i = yPos+1; i < 20; i++)
             {
                 finalVal += array5[i, xPos];
             }
         }
         //check the right sides until you
         //reach a row of all 0's
         while (allZerosR == false)
         {
             allZerosR = true;
             //for loop #1 (right)
             for (int j = xPos+1; j < 27; j++)
             {
                 allZerosR = true;
                 //loop that goes through each
                 //block in a column
                 for (int k = 0; k < 20; k++)
                 {
                     finalVal += array5[k, j];
                     if (array5[k, j] != 0)
                     {
                         allZerosR = false;
                     }
                 }
                 //check if we found a column 
                 //of 0's
                 if (allZerosR == true)
                 {
                     j = 28;
                 }
             }
             //allZerosR = true;
         }
         //check the left sides until you
         //reach a row of all 0's
         while (allZerosL == false)
         {
             allZerosL = true;
             //for loop #2 (left)
             for (int l = xPos-1; l > 0; l--)
             {
                 allZerosL = true;
                 //loop that goes through each
                 //block in a column
                 for (int m = 0; m < 20; m++)
                 {
                     finalVal += array5[m, l];
                     if (array5[m, l] != 0)
                     {
                         allZerosL = false;
                     }
                 }
                 //check if we found a column 
                 //of 0's
                 if (allZerosL == true)
                 {
                     l = 0;
                 }
             }
             //allZerosL = true;
         }
 
         print(finalVal);
         return finalVal;
     }
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

22 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Trigger to make another trigger to appear? 2 Answers

Can't figure out how to use multiple triggers in single scene 1 Answer

Boolean wont acitvate if the enemy enters a trigger 1 Answer

Need help making an audio trigger. 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges