- Home /
How do you get curve values on an animation clip playing from a timeline?
How do you get curve values on an animation clip playing from a timeline?
Specifically, I have a timeline with a track that plays a series of animation clips in sequence for my scene's main camera. These animation clips contain a floating point curve for the camera's field of view, but I can't figure out how to access this curve in script. I can see the curve in the Animation window so I know it's there. I first tried Animator.GetFloat
, but it always returns 0 for the property in question; then I came across this thread on the Feedback forum from 2015 where user Guessmyname says:
If you want to call get/set parameter functions on an AnimatorControllerPlayable you need to call them on the Playable not the Animator; the Animator's Get/Set parameter functions are for it's runtimeController, which needs to be null for it to playing Playables.
However, first of all I can't find any GetFloat
function related to Playables when I search for it in the script API documentation; and secondly, I'm really confused how to get the playable that the timeline is playing on my camera's Animator in the first place. I can get the playableGraph, and from there I can see methods to get outputs and root playables - but looking at the documentation for the classes, interfaces, and extension functions, I can't find anything that appears to take the name of a curve and return a float value from it.
For my current scenario I am trying to set the field of view for my camera, but for future use I would love to know a general solution that works for any float curve in an animation clip played from a timeline. As a last-resort workaround I am considering asking the animators to add a dummy object to their Maya scenes and output the field of view values (etc.) to its position.
I am using Unity version 2018.2.7f1.
UPDATE
I just now learned from someone in another company working on the same project that as of 2018.2 Unity now supports importing the camera's focal length directly from Maya if "Physical Camera" is enabled, although I am still yet to find this information in the official documentation. The script documentation for Camera.FocalLengthToFOV lists a sensorSize
parameter, so, not being familiar with all of Maya's camera-related parameters, I foolishly assumed this was related to VR headsets.
However, while this solves my immediate problem, I still don't have an answer for my question in general: how does one retrieve values from arbitrary curves by name from an animation clip playing from a timeline? The camera's field of view is not necessarily my only use case.
On an unrelated note, is there a way to insert blank lines between paragraphs on this site's flavor of $$anonymous$$arkdown? All my paragraphs are squished together...
Your answer
![](https://koobas.hobune.stream/wayback/20220612180934im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Timeline: play different animations by hitting different triggers with different colliders 2 Answers
Timeline: gameObject animation is played differently 1 Answer
How can I make the animation timeline more intuitive ? 0 Answers
How to make a model move during timeline in Cinemachine. 0 Answers
Can the animation editor create local rotational data? 3 Answers