Search Unity

Question We can't put animator component on random GameObject ?

Discussion in 'Animation' started by Pytchoun, Mar 5, 2023.

  1. Pytchoun

    Pytchoun

    Joined:
    Apr 12, 2015
    Posts:
    203
    Hi,

    I would like to put my animator on child gameobject for cleaning my hierachy but my animator only work if i put my animator on main gameobject.
     
  2. Unrighteouss

    Unrighteouss

    Joined:
    Apr 24, 2018
    Posts:
    599
    You can put animator components on any object in the scene, but your animations or scripts may not work.

    Animations use string references (the name of objects and their parent relationships) to know which objects to move, so changing an animator to a different object might break the animations on that animator controller.

    Scripts that reference an animator may also stop working if you swap that animator to a different object.
     
  3. Pytchoun

    Pytchoun

    Joined:
    Apr 12, 2015
    Posts:
    203
    How to fixe that ?
    I use mixamo animation.
     
  4. Unrighteouss

    Unrighteouss

    Joined:
    Apr 24, 2018
    Posts:
    599
    You can tell if your animations are broken if they have yellow references like this:

    Missing Reference.JPG

    Make sure you click on the object with the animator, not the animation in the project window to see if the references are okay.

    To fix this, you can manually rename them by slow double clicking on each one.

    I use a script to rename them all at the same time: https://github.com/s-m-k/Unity-Animation-Hierarchy-Editor

    There's a README file included that will tell you how to use it.

    If you need any help, just let me know.
     
  5. Homicide

    Homicide

    Joined:
    Oct 11, 2012
    Posts:
    657
    Just to add here, but sometimes, there just is a logical place for such a component, and completely unreasonable places for it to be as well.

    In the case of a character, its almost 100% guaranteed you do not want your animator attached to a leg object in the rig. But im sure obvious is obvious. GL.
     
    Unrighteouss likes this.