iTween-Error :: "Cannot cast from source type to destination type"

Hi there!

I got this error

Cannot cast from source type to destination type.

when I use this script to move the camera

function OnMouseEnter()
    camPosX = cam.transform.position.x;
    camPosY = cam.transform.position.y;
    if(!isActive) iTween.moveTo(cam,{"y":(camPosY+100), "x":(camPosX + 100) , "time":2, "transition":"easeOutExpo"});

function OnMouseExit()
    if(isActive) {
    iTween.moveTo(cam,{"y":camPosY, "x":camPosX, "time":1, "transition":"easeOutExpo", "onComplete": toggleActive});
function toggleActive()
    isActive = !isActive;
    Debug.Log("isActive: " + isActive);

Why is that?


Actually you'll need cam to be a GameObject and the callback needs to be sent as a string: "onComplete": "toggleActive"

Hope that helps!

It probably needs to be cam.transform for all of those cam references - i haven't used the library but my guess is it takes transforms to move objects