Search Unity

why does AnimationClip.SampleAnimation need a gameobject?

Discussion in 'Animation' started by soondolking, Jan 28, 2020.

  1. soondolking

    soondolking

    Joined:
    Nov 30, 2017
    Posts:
    2
    i don't understand why sampling a position or a rotation even needs a gameobject!
    animationclips are meant to be shared with various gameobjects, and sampling is just getting animation data at certain time. isnt it?

    I've always had no problem getting interpolated data of any bone from an animation at given frame when developing PC games. but i just can't find any way to do just that in unity!! i've used a whole day just searching in the forum and all i get is this SampleAnimation which need a gameobject.

    Please..can someone tell me that there is a way to get position/rotation of a bone at given time from an animationclip?
    Or that there is a cached animation data that we can get from the fbx importer or something?

    P.S. i know about the editor - GetCurve but, i really don't want to use more memories reading some data that otherwise can be earned rather easily at runtime.
     
  2. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,570
    Because ... I have no idea why, you just can't. You can access custom curves in an Animator Controller by creating a parameter with the same name for it to automatically update, but that doesn't apply to general bone control curves. Getting the curves you want in the Editor and serializing them separately is the only option I know of.