- Home /
itween Error - InvalidCastException:
i tried to use itween by creating a path in a string which is made from arrays and loops to create the path.
code is iTween.MoveTo(gameObject, iTween.Hash("path", tempPath, "time",5));
sample string would be tempPath = "new Vector3[]{new Vector3(-33.7, 0.8, -32.9), new Vector3(-33.7, 0.8, -27.2), new Vector3(-33.7, 0.8, -21.5), new Vector3(-33.7, 0.8, -15.4), new Vector3(-33.7, 0.8, -9.0), new Vector3(-33.7, 0.8, -3.6), new Vector3(-33.7, 0.8, 2.9), new Vector3(-33.7, 0.8, 9.3)}"
but I get the error
InvalidCastException: Cannot cast from source type to destination type. iTween.GenerateMoveToPathTargets () (at Assets/Plugins/iTween.cs:3523) iTween.GenerateTargets () (at Assets/Plugins/iTween.cs:3162) iTween.TweenStart () (at Assets/Plugins/iTween.cs:4603) iTween+c__Iterator2.MoveNext () (at Assets/Plugins/iTween.cs:6567)
any suggestions?
update:
when I add the string in manually so it looks like:
iTween.$$anonymous$$oveTo(gameObject, iTween.Hash("path", new Vector3[]{new Vector3(-33.7, 0.8, -32.9), new Vector3(-33.7, 0.8, -27.2), new Vector3(-33.7, 0.8, -21.5), new Vector3(-33.7, 0.8, -15.4), new Vector3(-33.7, 0.8, -9.0), new Vector3(-33.7, 0.8, -3.6), new Vector3(-33.7, 0.8, 2.9), new Vector3(-33.7, 0.8, 9.3), new Vector3(-33.7, 0.8, 15.2), new Vector3(-33.7, 0.8, 21.2)}, "time",5));
I get the errors: - Assets/_Scripts/Player/PlayerController.cs(112,115): error CS1502: The best overloaded method match for UnityEngine.Vector3.Vector3(float, float, float)' has some invalid arguments - Assets/_Scripts/Player/PlayerController.cs(112,115): error CS1503: Argument
#1' cannot convert double' expression to type
float'
Your answer
![](https://koobas.hobune.stream/wayback/20220613114346im_/https://answers.unity.com/themes/thub/images/avi.jpg)