iTween MoveTo + Rotation?

Hello everyone.

I’m using iTween’s MoveTo to move my gameobject along a path and everything works fine.

My problem is, the rotation of the gameobject stays the same while he is moving along the path.

I want him to rotate in the direction of the path.

This is my line of code:

iTween.MoveTo(gameobject, iTween.Hash("path", iTweenPath.GetPath("MyPath"), "time", 500));


As the iTween documentation shows-

You can use the “orienttopath” property to orient to its direction of travel and the “lookahead” property to influence how strict “orienttopath” is and how much the object will anticipate each curve.

“orienttopath” is a boolean so you should set it to true, “lookahead” should be set to a value between 0 and 1 depending on how you want your gameobject to react.

Your final code would look something like this-

iTween.MoveTo(gameobject, iTween.Hash("path", iTweenPath.GetPath("MyPath"), 
     "orienttopath", true, "lookahead", .5f, "time", 500));

You can use iTween :
iTween.MoveTo(gameObject, iTween.Hash(“path”, iTweenPath.GetPath(“New Path 1”), “time”, 50, “orienttopath”, true));

By this line of code your object will follow the path and will run along that path only.

if you use 2D project:
replace itween class with iTween.txt in attach. and change or add :

 void Awake()
            iTween.dimensionMode = iTween.DimensionMode.mode2D;

enjoy :slight_smile: