Search Unity

Bug 2022.1.0f1: Sprite Resolver vs. Animator?

Discussion in '2D' started by pryankster, May 17, 2022.

  1. pryankster

    pryankster

    Joined:
    Aug 6, 2015
    Posts:
    24
    I'm trying to animate a sprite using the SpriteLibrary and SpriteResolver components. I have an AnimationClip which contains a single track: "Sprite Resolver.Sprite Hash", with keyframes containing references to the frames that I want displayed. When I play the animation manually in edit mode, it looks perfect. When the animation plays in Play mode, something is hammering the sprite back to it's original shape inbetween keyframes (the sprite animation is set to 12 samples). If I single step, I can see the animator set the frame correctly, and then the next step the shape reverts back to its default image.

    Seems like a bug to me? but maybe I'm doing something wrong?

    (I know about animation curves, and about tangents -- that's not applicable here, because this version has removed the curve for the Sprite Hash track)

    -- pryankster
     
  2. Ted_Wikman

    Ted_Wikman

    Unity Technologies

    Joined:
    Oct 7, 2019
    Posts:
    916
    Hello @pryankster
    In your Animator Controller, do you have multiple clips, or only the one you are referring to in your post? And when you say "play the animation manually in edit mode", what does manually mean?
     
  3. pryankster

    pryankster

    Joined:
    Aug 6, 2015
    Posts:
    24
    My animation controller does have multiple clips, but I can see that it's only playing the "idle" clip (progress bar moving across the idle box in the animation controller window.

    "play the animation manually" means either scrubbing the animation clip timeline with the mouse, or, clicking the "preview play" button on the animation timeline window.

    EDIT: I made a copy of my animation controller and removed all other animations states except for the idle clip. The animation worked smoothly! So, I went back to the original and started removing clips/states one at a time ... the animation was jerky until I had removed all other states. i.e.: it only works when there's only a single "idle" state.

    Next, starting with a working animation controller with a single "idle" state, I added an empty state to the animation controller (no clip attached). It still worked.

    So, I added another state to the controller, a "walk" state. No exit time, 0 transition, exit condition "speed > 0.01", and transition back to "idle", No exit time, 0 transition, exit condition "speed < 0.01". The jittering returns!

    On a lark, I removed the transitions from "idle" to "walk" (there are now no paths back to "walk")... it STILL jitters! So, once again, I removed the "walk" state (which had NO transitions connecting to it), and the "idle" animation works, and is smooth again.

    --pryankster
     
    Last edited: May 18, 2022
  4. Ted_Wikman

    Ted_Wikman

    Unity Technologies

    Joined:
    Oct 7, 2019
    Posts:
    916
    Thanks for trying things out and reporting back to the thread. My guess is that you have hit the following limitation:
    (From the Sprite Swap section in our 2D Animation documentation)

    Let me know if this is the case!
     
  5. pryankster

    pryankster

    Joined:
    Aug 6, 2015
    Posts:
    24
    Ah! I saw that limitation, but I didn't put 2+2 together. I'm in the process of shifting over my animation clips from using SpriteRenderer.sprite to using SpriteResolver.

    I moved all of my clips to use SpriteResolver and the problem went away. Thanks for the heads-up!

    -- pryankster
     
    Last edited: May 19, 2022
  6. Ted_Wikman

    Ted_Wikman

    Unity Technologies

    Joined:
    Oct 7, 2019
    Posts:
    916
    Great, thanks for confirming!
    Let us know if you face any other issues in the future, and best of luck with the project!