iTween, Catmull-Rom and LookTarget

Hi there, I’m using the wonderful iTween to make a gameobject follow an array of Vector3’s which forms a route for an object. Previously, I was moving the object to each subsequent vector3 position in an array and using “looktarget” to ensure it was looking towards the next position - all worked well.

However, I wanted to smooth the movement, so I used Catmull-Rom and since doing this (as you simply supply the entire array of positions/transforms) the looktarget no longer works.

Is there anyway to have the best of both worlds - so the catmull-rom smoothing and the object to face it’s next position?

Thanks for any help

Using iTween.MoveTo, you can provide a hashtable as a parameter. You can use this hashtable to set the parameters of your movement.

Example:

Hashtable parameters = new Hashtable();
parameters.Add("path", vectorArray);
parameters.Add("time", 5.0f);
parameters.Add("orienttopath", true);
iTween.MoveTo(gameobject, parameters);

If “orienttopath” value is true, your gameobject will orient to its direction of travel.
If you add “path” key with a value of vector3 or transform array, iTween will create a curved path and follow it. If you do not want a curved path, provide 1 vector3 or transform instead of an array as value of “position” key.

For detailed information, check iTween documentation in its website.