iTween: Cannot cast from source type to destination type.

Hi!

I use the following code to test the animation before writing a bunch of code:

Vector3 _position = new Vector3(326, -30, -1);
GameObject _boat = (GameObject)Instantiate(boatPrefab, _position, Quaternion.identity);
iTween.MoveTo(_boat, iTween.Hash("path", path, "speed", "10", "orienttopath", "true", "easetype", "easeInOutSine", "oncomplete", "complete"));

And got an error:

InvalidCastException: Cannot cast from source type to destination type.
iTween.GenerateMoveToPathTargets () (at Assets/iTween/Plugins/iTween.cs:3580)
iTween.GenerateTargets () (at Assets/iTween/Plugins/iTween.cs:3158)
iTween.TweenStart () (at Assets/iTween/Plugins/iTween.cs:4598)
iTween+c__Iterator8.MoveNext () (at Assets/iTween/Plugins/iTween.cs:6555)

Any help will be appreciated.

Hello. Your MoveTo-function has some invalid arguments. Try to write it like that:

public Transform boatPrefab;
	
	// Use this for initialization
	void Start () {
		Vector3 _position = new Vector3(326, -30, -1);
		GameObject _boat = (Instantiate(boatPrefab, _position, Quaternion.identity) as Transform).gameObject;
		iTween.MoveTo(_boat, iTween.Hash("path", iTweenPath.GetPath ("path"), "speed", 2, "orienttopath", true, "easetype", iTween.EaseType.easeInOutSine, "oncomplete", "complete"));
	}
	
	void complete(){
		Debug.Log ("complete");
	}

I dont know if your variable path is a vector or anything else. I created a path with the name path. To create the path I used the iTweenPathEditor.
The project of this example: [6677-new+unity+project+1.zip|6677]

If you want to make it without iTweenPath:

void Start () {
  Vector3 _position = new Vector3(326, -30, -1);
  Vector3[] path = new Vector3[2];
  path[0] = new Vector3(326, -30, -1);
  path[1] = new Vector3(320, -20, 0);
		
  GameObject _boat = (Instantiate(boatPrefab, _position, Quaternion.identity) as Transform).gameObject;
	
  iTween.MoveTo(_boat, iTween.Hash("path", path, "speed", 20, "orienttopath", true, "easetype", iTween.EaseType.easeInOutSine, "oncomplete", "complete"));
}