Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 OBV10U3_NINJA · Sep 06, 2015 at 12:39 PM · triggerdetectionboundarytetrisregion

Area sensing - Needs fixing

I am working on a game called Cubit, a 3d morph of Tetris. How it works, basically, is that you have to fill up a layer on the outside of a cube (which you can rotate, similar to rotating blocks in normal Tetris). You can only work on the layer you are on, and not outside of it. Cubes too far off to the right, top, left or bottom would "pop".

I am trying to make it so that when a cube tries to become solid outside of the level's bounds, it pops, like I described -

 if (Input.GetKeyDown(KeyCode.L)){
     if (transform.position.x + cubeCursor.transform.position.x > (-1 - Tetris.lvl) &&
         transform.position.x + cubeCursor.transform.position.x < (1 + Tetris.lvl) &&
         transform.position.y + cubeCursor.transform.position.y > (-1 - Tetris.lvl) &&
         transform.position.y + cubeCursor.transform.position.y < (1 + Tetris.lvl) &&
         transform.position.z + cubeCursor.transform.position.z < (-1 - Tetris.lvl) &&
         transform.position.z + cubeCursor.transform.position.z < (1 + Tetris.lvl)) {
 
         Materialize();
 
     } else {
         Destroy(gameObject);
     }
 }

The cubes you are placing are parented to the cursor, which shifts left-right and up-down. I figured this would work just fine, but the area they are solidifying in is not where I told it to be. alt text

They should be able to materialize in the 4x4x4 region outside the central cube. However, they are limited to a much smaller region. The Tetris.lvl variable affects the size of this region, and thus the level that is being worked on. Anyone got ideas on what's going wrong?

cube1.png (111.3 kB)
Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by OBV10U3_NINJA · Sep 06, 2015 at 07:20 PM

I fixed it myself. The process itself is highly complex, and I am unable to put the entire thing here, but to be basic, instead of spawning the cubes at a position from the cursor, I made a script for them to move after they are created. It involves a lot of switch statements and methods.

However, I will show you a bit of it - I came up with an ingenious way of having the blocks figure out where they are supposed to go. In a script, I made a globally accessible integer, called "HoloCounter", which counts the hologram-cubes. In the start function of each cube, I have it so they increase it by one, taking advantage of the fact that the computer runs the whole way through the functions of one object before going through the functions of the next. Then I made a bunch of methods, "TetraPattern1" through "..7" (which are based off of the chosen cube pattern), and in each, did variations of this -

 void TetraPattern1 () {
         switch (CubePlacer.HoloCounter){
         case 1:
             break;
         case 2:
             transform.Translate(0f,1f,0f);
             locX = 0;
             locY = 1;
             break;
         case 3:
             transform.Translate(1f,0f,0f);
             locX = 1;
             locY = 0;
             break;
         case 4:
             transform.Translate(1f,1f,0f);
             locX = 1;
             locY = 1;
             break;
         default:
             print ("Too many holocubes or HoloCounter not working properly");
             Destroy(gameObject);
             break;
         }
     }

Impressed?

Comment
Add comment · Show 1 · 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 OBV10U3_NINJA · Sep 06, 2015 at 05:23 PM 0
Share

EDIT - The purpose of the difference here, is the locX and locY integers are used in place of the transform.position.x and y positions. I also removed the transform.location.z ones. I don't know why it worked, but it did.

 if (Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.L)){
             if ((locX + CubePlacer.cubeCursorX > (1 - Tetris.lvl)) &&
                 (locX + CubePlacer.cubeCursorX < (4 + Tetris.lvl)) &&
                 (locY + CubePlacer.cubeCursorY > (1 - Tetris.lvl)) &&
                 (locY + CubePlacer.cubeCursorY < (4 + Tetris.lvl))){
 
                 $$anonymous$$aterialize();
 
             } else {
                 Destroy(gameObject);
             }
         }

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

2 People are following this question.

avatar image avatar image

Related Questions

Least heavy processing detection method 1 Answer

OnTriggerEnter2D not Working 0 Answers

Full Performance On Melee Combat 0 Answers

Trigger Detecting Player Even When Not Inside 1 Answer

Detecting contact on colliders? 0 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