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
2
Question by Silx · Mar 22, 2012 at 07:07 PM · c#instantiateclassesdesign

Tetris Unity game structure C#

As a budding developer, my biggest issue with Unity seems to be figuring out how to structure a game from the outset. Once the structure is in place though, I seem to do fine in getting all the systems and code to work great.

I'm struggling to figure out how to set up a game like Tetris within Unity. Using standard design, I could create the classes and the game itself without prefabs, but that seems to go against the nature of what Unity is all about. I would rather take the 'object with components' approach.

How would you set up Tetris within Unity? I'm using primitive cubes as the blocks that make up the shapes.

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

3 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by Maylina · Nov 19, 2017 at 01:57 PM

It is not reusable to make everything depends on Unity. Better to use 2D Arrays and draw block according to array data.

Here sources of such tetris game: http://doctrina-kharkov.blogspot.com/2017/11/kak-napisat-tetris-c-sharp-unity-1.html

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 Meltdown · Mar 22, 2012 at 07:35 PM

Simple. Just create a model for each shape piece, then add a mesh collider. As the pieces fall and connect with another piece, set them to isKinematic = false so they stop moving.

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 ptpaterson · May 31, 2012 at 12:29 AM

I am looking around for ideas relating to a tetris game, too. Probably more like the Japanese game, puyo puyo, but the details I would think are similar.

I wouldn't use the in game physics by making the blocks rigid bodies. Rather, you could create a 2d array to store all of the positions of the fallen blocks/pieces/gooballs. You could restrict the falling pieces to the grid as well, or let them move more freely and use the colliders to determine when the falling piece has landed. When a falling piece collides with a landed piece, then you could start a timer only allowing the piece to rotate or move down. Then you can store that piece in your array and calculate whether to eliminate a row or a group of pieces or whatever. You would have complete control over how the pieces move, and I think it would make for MUCH smoother gameplay.

You could still use cubes to represent the pieces as a start, or use any other mesh and use a box collider around it. But if you use the built in physics than it might end up bouncy and harder to control, like this video I just found.

I think that prefabs would be great for things like the differently shaped pieces. Though it might not be so necessary for the interface.

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

7 People are following this question.

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

Related Questions

Instantantiate relative to parents position 1 Answer

AddComponent() causes a "trying to create a MonoBehaviour using the 'new' keyword" warning 2 Answers

Camera follow script not following player? 1 Answer

How do i Instantiate a prefab with specific assests included 3 Answers

Properly reverting to a cashed state 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