- Home /
Question by
jannis99 · Feb 10, 2014 at 05:14 PM ·
erroritweenienumerator
iTween + IEnumerator: InvalidCastException: Cannot cast from source type to destination type.
I get the Error "InvalidCastException: Cannot cast from source type to destination type.", when I tried to use this script:
void OnTriggerEnter(Collider other)
{
...
direction = new Vector3(1, 0, 0);
StartCoroutine(Boost());
...
}
IEnumerator Boost()
{
...
iTween.MoveBy(gameObject ,iTween.Hash("amount", Vector3.Dot(new Vector3(bd, bd, bd), direction), "space", Space.World, "time", bd));
yield return new WaitForSeconds(bd);
...
}
(bd is an integer)
I don't understand this Error. Could you help me? Thanks!
Edit: The Error occured in the iTween-Script.
Edit: I have solved the problem by changing "Vector3.Dot(new Vector3(bd, bd, bd), direction)" into
new Vector3(bd * direction.x, bd * direction.y, bd * direction.z)
I still don`t know where I did the mistake, so please tell me if you do, but now it works :-) .
Comment