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 AngelisDragon · Jun 16, 2013 at 03:02 AM · gameobjecttriggermoveitween

How would I go about moving a group of objects as one using iTween?

Well. What I actually have at the moment is a trigger to create a trigger, which when entered needs to move a group of objects as one across the floor. I just don't know how to achieve this with iTween. Would I create many variables and use assign a game object to each, or would I group them all as one game object and then use iTween to move them?

Thanks :D

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 DannyB · Jun 16, 2013 at 07:25 AM

There are several ways to do it, each more suitable to different situations.

Option 1: Grouped Objects
If it makes sense to have the objects you are about to move parented to a single object throughout the game, then you should consider doing it. For example, if you want to move the entire background, have it pre-grouped under one object.

Option 2: Objects are responsible for moving themselves
In some cases, you would make your objects respond to some event, and they will activate their own iTween on themselves.

Option 3: Centralized controller moving other objects
This situation may work when you want to move all objects that are tagged the same, or that you already have a reference to.

Option 4: Grouping on demand
May be suitable for some cases - this is the same as the previous option, only instead of calling iTween for each object, you first parent them and then use one iTween on the parent.

All in all, your question is actually not only iTween related, but it seems like you are trying to figure out a way to handle multiple objects in the same way. This is a different question.

I am usually using option 2.

EDIT:

Skeleton for implementing event listeners
A little more details about option 2 as requested. This is one way of doing it, there are more of course, depending on the situation.

The object that controls this movement, declares an event:

 public class MyController {
     public delegate void BangEvent( float direction ); 
     public static event  BangEvent onBang;
     ...


Then, whenever you want to trigger (raise) this event (from the same object), you do:

 if( onBang != null ) onBang( direction )

Finally, your other objects (ones that should move), subscribe to this event.

 void OnEnable() {
     MyController.onBang += OnBang;
 }

 void OnDisable() {
     MyController.onBang -= OnBang;
 }

 void OnBang( float direction ) {
     iTween.MoveBy( gameObject, ... );
 }

Comment
Add comment · Show 5 · 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 AngelisDragon · Jun 18, 2013 at 05:50 AM 0
Share

So if I group them all to a specific object (say, an empty game object), will this mean that I can declare my gameObject variable the empty game object, and, in turn, the objects grouped with it?

avatar image DannyB · Jun 18, 2013 at 06:54 AM 0
Share

Yes. Grouping them under an empty object and then iTween.$$anonymous$$oveTo( thatEmptyGameObject, ... ) will move all of its children with it.

avatar image AngelisDragon · Jun 18, 2013 at 07:02 AM 0
Share

I see. And your option 2, how would you go about doing this?

avatar image DannyB · Jun 18, 2013 at 07:15 AM 0
Share

I like option 2. I have extended the answer, but this is a whole other topic... :)

avatar image AngelisDragon · Jun 18, 2013 at 07:30 AM 0
Share

Wow... Awesome. Thanks :D

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

15 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

Related Questions

Can I move a component from one GameObject to another in script? 1 Answer

Trigger moves another object 1 Answer

Object moving OnTriggerEnter, please help?! 2 Answers

Moving object with a trigger? 0 Answers

check if object is moving 5 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