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 /
This question was closed Apr 19, 2018 at 04:07 PM by VeraDu for the following reason:

The question is answered, right answer was accepted

avatar image
1
Question by VeraDu · Apr 13, 2018 at 05:34 PM · gridpositioning

How can I position a number of gameObjects on one line and then move them together?

In my game every period of time spawns a number of blocks, then all of them move down as one line. For player it should look like this line is not devided on blocks. Max amount of blocks in line - 7, but can be situations, when number of block are missing in different positions, for example it can look like: ||||||| - when all line is filled. |||.|.. - when some blocks are missing(. is empty space) or the line could be empty at all. But in any way this line should have some element, that will trigger, when it riches the bottom of the screen, so that another line spawns at the top and the screen is never empty. This game looks like Piano Tiles, I guess . So the question is: what would you use to position block correctly and to have a trigger element? I thought, that I could use Grid layout Group to position blocks on it, and then move it down to the bottom of the screen, but I didn't get how to work with it correctly and if it can do what i need at all.

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

  • Sort: 
avatar image
1
Best Answer

Answer by tormentoarmagedoom · Apr 13, 2018 at 06:23 PM

Good day.

First, you have to Instantiate an EmptyObject (lets call "Line"), which will be the parent of all blocks of the line.

 GameObject LineToInstantiate = Instantiate (LinePrefab, position, rotation);

Then, instantiate all objects as a child of "Line", and change its LocalPosition (position relative to parent)

 GameObject  CubeToInstantiate = Instantiate (CubePrefab, LineToInstantiate.transform);
 CubeToInstantiate.transform.Localposition = new Vector3 ( 15 , 0, 0 ) ;

PD: Don't copy the code, maybe have typing errors :D :D

Now, you have a Object called "line" which contains the blocks you just instantiated.


If helped, accept the answer and close the question!

Bye!

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

Follow this Question

Answers Answers and Comments

78 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 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 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 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

Creating a Procedural Grid positioning problems 0 Answers

All child objects has a localPosition.y of 0 0 Answers

How can i change cell grid position dynamically in unity 0 Answers

infinite 2d grid in an Editor Window 1 Answer

How to create a 2D grid based array with passable/impassable grids for movement ? 1 Answer


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