• 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
1
Question by jimbobuk · Dec 29, 2009 at 02:31 AM · gameobject

How can I easily dynamically move a stack of gameobjects?

I'd like to move a stack of gameobjects - like a pile of bricks - intuitively and quickly in code. I've already got the pile of gameobjects in the world and would ideally like to transfer them around whilst staying piled together as they currently are.

I'm wondering if perhaps i could do the following

  • have a carrying empty gameobject
  • position carrying gameobject at the centre bottom of the pile in the world
  • add each gameobject brick as children to the gameobject
    • it's crucial that in doing this the gameobject will stay in exactly the same world position
    • yet i guess their actual positions that are now relative to the carrying game object will need to be altered into the correct space?
    • once all gameobjects are added i can then simply translate the carrying game object around to move the pile of objects
    • after placing where desired I can then move each of the gameobjects out of the carrying gameobject hierarchy and back into the world root (or another suitable gameobject hierarchy)
    • if any space transformations were needed putting them into the carrying gameobject then i guess they'll need to be reversed here
    • the carrying gameobject can be left till its services are required again

It all sounds relatively straight forward, i guess the crux is

  • can you dynamically create hierarchies of gameobjects at runtime?
  • are space transformations required when objects are moved into and out of new hierarchies?
  • what members and functions are required to accomplish this?

Cheers

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
2
Best Answer

Answer by Ashkan_gc · Dec 29, 2009 at 07:40 AM

you can do this easily. you just need to set the transform.parent of each block to your parent gameobject and then set it back to null. there is no need to space transformations. go ahead and use great easy to use powerful unity!

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 jimbobuk · Dec 30, 2009 at 12:34 AM 0
Share

cheers.. So long as the carrying gameobject was positioned where i wanted it relative to the future children then yes it was very straightforward.. Joy! :)

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

How to add Forces and Torques relative to an object at a none central position 2 Answers

Is FindGameObjectWithTag() too heavy on resources for 50 objects? 0 Answers

Using script's method from all of the gameobjects that has that script 2 Answers

Unity Editor Scripts: GameObject Added / Removed Event? 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