- Home /
iTween : moving along path, within a rotating reference frame
Hi, trying to do something quite tricky.
I want to move a missile along a predefined path with iTween. Nothing tricky here, except that I want this to happen inside a rotating environment. For some reason, all of my game objects stand in an empty game object which constantly spins, as if the world space itself was in motion.
I found a way to handle this (for those interested, more details at the end of this message), but there is one last problem I could’nt solve : the orientation of the missile. I want it to orient along its path, so I use the orienttopath parameter. This works perfectly in a static world, but not in a rotating one. I need my orientation to be « local », that is to say relative to the path space, not to the world space. Any way to do this ?
Thanx in advance and congratulations to the iTween’s author. I keep beeing amazed by the way this nice asset empowers Unity and celebrates the beauty of mathematics !
To translate along path within a moving reference frame :
Make an empty GO with a script that moves or rotates it. This will stand for your « moving world », and all of your GO’s should be childed to it.
For each point on the path, instantiate navpoints. These are simple Transforms that you will also child to the « rotating world », so that their positions keep being updated. It is important to make a navpoint for the start of the path and one for its end, not only for the intermediate points.
Store their localPositions in an array of Vector3. This will be your path.
Use iTween.MoveTo() as described in the example below. The « orienttopath » param should be set to false, until someone solves this specific problem
Some code example :
Vector3[] path = new Vector3[] { startPoint.localPosition, navPoint1.localPosition, navPoint2.localPosition, endPoint.localPosition, }; iTween.MoveTo(myGameObject, iTween.Hash( "path", path, "time", 3f, "orienttopath", false, "islocal", true, "movetopath", false));
Your answer
![](https://koobas.hobune.stream/wayback/20220612215921im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
iTween with multiple ValueTo calls on same GameObject 1 Answer
iTween PointOnPath percentage 3 Answers
Push an object along a path? 2 Answers
Enemy following the target with ITween 2 Answers
iTween & Boo 1 Answer