Search Unity

The animator seems like a big convoluted mess. Am I just using it wrong?

Discussion in 'Animation' started by Geo3, Jan 28, 2019.

  1. Geo3

    Geo3

    Joined:
    Sep 10, 2018
    Posts:
    1
    I'm doing 2D sprite animation on my player character and the animator seems like a tedious convoluted mess.

    There are 2 main issues that are getting to me. One is I that the number of transitions quickly become unmanageable. I only have about 1/4th of my over all states implemented so far and the thing already looks like an indecipherable spider web. It would be so much easier if I could directly set a state in code instead having to update parameters and have a hundred transitions.

    The other issues is I have several different versions of my player character. They will use different sprites and animations, but the states and logic for switching is identical. The best way I can see to tackle this problem is to make one animator and copy it after it's fully implemented and pray nothing ever needs to be changed later on. I would expect unity to have a better solution. Ideally the group of sprites used would just be a parameter I could change. If not that then have something like prefabs for the animation controller where I can make a change on one and have it propagate down to the others.

    Anyone have advice how to tackle these two problems? Are there features that I'm unaware of? As is the animator seems beyond clunky to use.
     
  2. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
    Yes, one word... Playables. Totally bypass Animator Controller.
     
    Geo3 likes this.
  3. bart_the_13th

    bart_the_13th

    Joined:
    Jan 16, 2012
    Posts:
    498
    You can just change animation clips at runtime...
    Here's my before and after animation change implementation...
    web.jpg
     
  4. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,570
    You might be interested in my Animancer plugin which lets you use a code based approach instead of creating AnimatorControllers.
     
  5. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    957
    You can set a state (by name) in code using either Animator.Play() or Animator.CrossFade(). Generally, you can do this in place of Any State -> transitions. If you need to transition directly from one state to another, then you would probably want to keep the explicit transitions, although you could have a script monitor the normalizedTime of the current AnimationState or listen for an AnimationEvent that you set up on an animation clip. (And then use Play() or CrossFade() to start a different animation clip)

    Unity does have a better solution: the Animator Override Controller. :)

     
    Geo3 likes this.