- Home /
iTween Path 2D rotation, orientToPath issue.
I'm using iTween Paths to set up enemy movement in a 2D space shoot shooter game I'm working on. The only problem I've run into is that I can't seem to properly orient to path, as the ship can never seem to point in the direction it's moving, nor does it continue moving in any particular orientation. It seems to move in whichever direction is the most convenient at the time.
This is the iTween code, currently:
void Start ()
{
iTween.MoveTo(gameObject, iTween.Hash("path", iTweenPath.GetPath("path1"),"axis","x", "orientToPath", true, "time", 20, "easetype", iTween.EaseType.easeInOutSine)); //"orientToPath", true,
}
And this is my result. (Which seems correct enough, but not what I want.)
http://www.youtube.com/watch?v=sP8BCXMPl28&feature=youtu.be
So, how would I go about fixing this?
Answer by PAHeartBeat · May 29, 2013 at 04:00 AM
iTween.MoveTo();
function just move your game object at point of which in next in your path, if you want to point your ship to next path point you have to add some extra code in update function to look out next point in path.
Do you know what function would be used in the update that would work, then?
Also, I'm not sure what you mean exactly. The function does update rotations, despite being in Start. You can see some rotation in the video, though I've locked it to the x-axis so the rotation isn't as obvious, though toward the end you can see the ship change direction. The main problem is that it isn't the nose of the ship which consistently leads the rotation along the path.