- Home /
Field of view scripted animation curve
Hello everyone, I'm trying to animate the field of view of a camera in a C# script, using Animation classes. Here's the code that does not work, no animation happens:
AnimationCurve curve_fov = AnimationCurve.EaseInOut(0, camera.fieldOfView , duration, 80);
clip.SetCurve("", typeof(Camera), "fov", curve_fov);
animation.AddClip(clip, "FOVAnim")
animation.Play("FOVAnim");
I had a lot of troubles finding the Field Of View property name (I found "fieldOfView", "fov", etc), I ended up using a script found in the web that shows all property names... why there's no common property dictionary in the documentation???
By the way this is not working...
Answer by Xroft666 · Oct 23, 2012 at 04:19 PM
Take it :)
using UnityEngine;
public class CameraAnimation : MonoBehaviour {
public AnimationClip clip;
void Start () {
AnimationCurve curve_fov = AnimationCurve.EaseInOut(0, camera.fieldOfView , 10, 200);
clip.SetCurve("", typeof(Camera), "field of view", curve_fov);
animation.AddClip(clip, "FOVAnim");
animation.Play("FOVAnim");
}
}
Thank you very much, it works... How did you find the right property name ("field of view") ????
I used some tricks you can find here:
http://answers.unity3d.com/questions/336397/override-transform-inspector-using-serializedobjec.html
Your answer
Follow this Question
Related Questions
Player is running just few seconds 0 Answers
weird animation problem in multiplayer 1 Answer
Playing animations problem 1 Answer
How to run an animation mouse click. 2 Answers
I try'd so hard, but my animation script doesnt work..? 1 Answer