Search Unity

Avatar prevent me from animating a public variable that I set up on my character

Discussion in 'Timeline' started by Yuevid, Mar 2, 2018.

  1. Yuevid

    Yuevid

    Joined:
    Dec 8, 2017
    Posts:
    5
    This is super strange, and I don't know how to solve it, some one please help.

    My character has 2D face, so I am animating it though a script with a number that I made as a public variable. The script is on the face mesh that is on the grandchild level of the character. Then I created a animation clip animating the number.

    I am putting the animation clip in the timeline to play, but it doesn't do anything, unless I get rid off the avatar on the animator of the character, and then it works, but of course I want my avatar on. (and that goes with not just that one variable, but everything script related animatable public numbers on the whole character)

    Can someone please help me understand why this happens? And is there a way around it? I would prefer not to add animator to the actual face mesh.:(
     
  2. DavidGeoffroy

    DavidGeoffroy

    Unity Technologies

    Joined:
    Sep 9, 2014
    Posts:
    542
    It sounds like you have two animators trying to animate the same value.
    Do you have an Animator on the grand-child object (the face I imagine)?
     
  3. Yuevid

    Yuevid

    Joined:
    Dec 8, 2017
    Posts:
    5
    I don't think I have, I figured out another solution, but thanks anyways
     
  4. Dioinecail

    Dioinecail

    Joined:
    Jun 1, 2017
    Posts:
    16
    Hi, i've encountered the same problem, how did you solve it???

    When i double click the animation track on the timeline, it shows that there are keyframes with values set for a variable (for example i have "IK_Weight" it animates from 0 to 1 over 2 seconds) and it animates inside the "Animation Window", but it does not inside the "Timeline Window" and it doesn't animate in play mode.

    I need the avatar for the animator because without it there is no IK feature, so...

    What strange is that some avatars work fine with timeline, while other break it.
     
  5. Dioinecail

    Dioinecail

    Joined:
    Jun 1, 2017
    Posts:
    16
    Moreover, usually when a variable is animated on the timeline, you cannot edit it inside the editor, which is understandable, because it is being animated by a curve. But with an "broken" avatar you can animate the variable, as if it's not animating anything on the script at all
     
  6. Dioinecail

    Dioinecail

    Joined:
    Jun 1, 2017
    Posts:
    16
    A possible solution is to put this script with a public variable on another object and make this script target the character animator and call OnAnimatorIK() from there


    Object 1 -> Target character which has any animator with IK Pass set to true and any avatar correctly set for the model
    Object 2 -> Object containing a script with OnAnimatorIK() which sets the IK targets for the Object 1

    A script on Object 2 would look like

    public Animator Anima; // Animator from Object 1
    public float ikWeight; // Weight of IK to animate
    public Transform ikTarget; // Target object of the IK (for example, a character wants to take a cookie, so put the cookie object in here

    void OnAnimatorIK() {
    // Set ik target, just follow the OnAnimatorIK docs in unity
    }

    But be sure to put an avatar on Object 2 that can animate variables and an animator with IK Pass set to true. This object does not need any model or something, just an Animator component with Animator Controller and Avatar set.