- Home /
iTween.MoveBy in 2D
Hi,
I want to use iTween.MoveBy in conjunction with orienttopath and I'm not able to succeed with it, even after reading the answers in itween Path, orientToPath and gameObject rotation, 2D game. Can somebody please help me?
My object is a ship, facing up in a ortographic camera. So y is facing up, x to the right and z to the back. As suggested in the linked answer I've put my ship into an empty GameObject with a x rotation of 270. So the blue z arrow is facing up and x is still facing to the right. The ship inside the empty GameObject has a x rotation of 90, so it's facing up again.
Through a trigger I'm executing now on the parent GameObject:
Hashtable ht = new Hashtable();
ht.Add ("orienttopath", true);
ht["amount"] = new Vector3(1, 1, 0);
ht["time"] = 2;
iTween.MoveBy(shipParent, ht);
It should move to the upper right. The movement direction is ok, but the ship rotates around the x axis, so it's looking inside the screen. I tried many other settings, but all the time it's behaving wrong. Can please someone explain how to fix that problem?
Answer by robertbu · Feb 10, 2013 at 03:09 AM
Typically when something is "oriented" it means that the forward vector is oriented which is the Z vector. You start with the the Z vector pointed to the back, so I suspect you really wanted the X vector to be considered as forward. You can fix this by using an empty game object to move along the path and make your object a child of the empty game object. Your object is then has a local rotation so that it is facing the way you want.
Thanks for your answer. Slowly, slowly I'm getting into it. At least
ship.transform.Translate(ship.transform.forward * speed * Time.deltaTime, Space.World);
is functioning now correctly. The Space.World seems to be very important.
Your answer
![](https://koobas.hobune.stream/wayback/20220613092425im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
[SCREENSHOTS] itween Path, orientToPath and gameObject rotation, 2D game 3 Answers
Using Itween with Unity 2D, sprite flips over while using orienttopath 1 Answer
iTween Path 2D rotation, orientToPath issue. 1 Answer
Path Controlled Character and Working With Physics on iTween 1 Answer
iTween 2D Path rotation 1 Answer