Make an object follow a curved path using iTween

Hi, I have asked a few questions now and have gotten responses for all so i am grateful and hope this trend continues. My current question is in regards itween. Say you have a cube at (0,0,0). How do you make it travel along a curved path? Bear in mind moveToBezier is deprecated in 2.0. A code snippet would be much appreciated. Thank you all in advance.

You can use iTween’s PutOnPath function.

Simple example:

Create “waypoint” gameobjects. (empty gameobjects). Then, assign those waypoints in the order you want to waypointArray.

	public Transform[] waypointArray;
	float percentsPerSecond = 0.02f; // %2 of the path moved per second
	float currentPathPercent = 0.0f; //min 0, max 1
		
	void Update () 
	{
		currentPathPercent += percentsPerSecond * Time.deltaTime;
		iTween.PutOnPath(gameObject, waypointArray, currentPathPercent);
	}
	
	void OnDrawGizmos()
	{
		//Visual. Not used in movement
		iTween.DrawPath(waypointArray);
	}

Keep in mind that PutOnPath may have some issues if your goal is to make a movement with constant speed. (I’m not going into detail because it isn’t what OP asked)

Replying to an old thread, but some may find this useful…

One can also use iTween.MoveTo() with a “path” attribute.
The path has to be an array of Transform or Vector3.

Here is an example :

public GameObject movingObject;
public Transform[] waypoints;
float speed = 2f;

 iTween.MoveTo(movingObject, iTween.Hash(
            "path", waypoints,
            "time", speed,
            "easetype", iTween.EaseType.easeInOutQuad));