- Home /
Move around a circle with iTween?
How can I move a GameObject
around a circle using iTween? I need something like this: iTween.MoveXXX()
. Is there any better way than using paths (because I image it would be possible to create a circular path)? I know it can be easily done with normal code (moving x
and y
with cos()
and sin()
) but there's a reason why I need to use iTween here.
Answer by robertbu · Apr 23, 2013 at 06:01 PM
You can rotate an empty game object using iTween and make the object that you want to move in a circle a child of the empty game object with an offset that places it on the circular path.
As an alternate, since you understand how to move an object in normal code, you can use similar code to generate the path and then use iTween functions to walk along the path.
@robertbu I used your first advice but have a strange problem. First of all, I wanted to move sth around a circle because I have an object whose pivot isn't at its center but in its corner (so if I rotated this object around a circle it should appear as if being rotated by its center). So after using your 1. advice my object (now a child of a dummy empty object) seems to be being rotated around an oval path ins$$anonymous$$d of circular. :P I don't know if it's $$anonymous$$E doing sth wrong or if it's iTween's issue. :P
You can try using a second empty game object. Place the second empty game object at the center of the object make the real object its child. $$anonymous$$ake the iTween rotated object the parent of the second game object.
So finally I would have another empty object in the very same position as the first one (positions of the first empty object and the real object same as before)? If so then I tried it and it didn't help (don't really know how that could help).
You said you had an object where the pivot was not at the center. So the second empty game object goes at the center of the object, not the pivot point. So the visible game object will be offset from the empty game object by the distance between the pivot and the center of the game object.
http://postimg.org/image/jahwi52zx Black quad is empty game object 1, red quad is empty game object 2, green star is visible real object, 1. is empty objects' and rotation's pivot, 2. is real object's pivot. Is this what you meant?