0
\$\begingroup\$

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?

\$\endgroup\$
-2
\$\begingroup\$

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/

\$\endgroup\$
  • \$\begingroup\$ 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. \$\endgroup\$ – Gnemlock Dec 14 '16 at 0:01
  • \$\begingroup\$ Oh, sorry my bad. Perhaps, solution could be to use iTween.Hash instead of normal Hashtable. \$\endgroup\$ – zhekazheka Dec 14 '16 at 7:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.