Unity3D: iTween ValueTo() not working

I have the following code to animate the Camera's FOV change:

public float fieldOfView;
public Camera theCamera;
public float animTime;

private float origFOV;

void OnTriggerEnter(Collider other) {
origFOV = theCamera.fieldOfView;

Hashtable h = new Hashtable ();
h.Add ("from", (float)origFOV);
h.Add ("to", (float)fieldOfView);
h.Add ("time", animTime);
h.Add ("onupdate", "OnFOVUpdate");

iTween.ValueTo(theCamera.gameObject, h);
}

void OnTriggerExit(Collider other) {
Hashtable h = new Hashtable ();
h.Add ("from", (float)fieldOfView);
h.Add ("to", (float)origFOV);
h.Add ("time", animTime);
h.Add ("onupdate", "OnFOVUpdate");

iTween.ValueTo(theCamera.gameObject, h);
}

void OnFOVUpdate(float val) {
theCamera.fieldOfView = val;
}


but I always get the following error when the script compiles:

iTween Error: ValueTo() requires an 'onupdate' callback function and a 'from' and 'to' property. The supplied 'onupdate' callback must accept a single argument that is the same type as the supplied 'from' and 'to' properties!

What am I doing wrong?

1 Answer

I think you, basically, have to do what is asking for. Implement onupdate function with parameters of the same row which your are planning to change.

Please find similar issue and solution here https://forum.unity3d.com/threads/itween-valueto.62448/

• It seems the requirement for implementing onupdate() was fairly obvious. I think it is the actual implementation asker is having trouble with, in the first place. – Gnemlock Dec 14 '16 at 0:01
• Oh, sorry my bad. Perhaps, solution could be to use iTween.Hash instead of normal Hashtable. – zhekazheka Dec 14 '16 at 7:02