Search Unity

[5.2.1p1] Problem when mecanim animation on the first frame

Discussion in 'Animation' started by StriderSeiryuu, Sep 28, 2015.

  1. dhiegolucio

    dhiegolucio

    Joined:
    Mar 2, 2016
    Posts:
    6
    Something that worked for me is to set the Update Mode as animate physics. Is not exactly the last frame (in my case) that blink, but was really annoying.
    Version 5.3.4
     
  2. AndyJRussell

    AndyJRussell

    Joined:
    Mar 21, 2016
    Posts:
    8
    We are also getting this bug in 5.3.5f1, I have managed to create a simple project which reproduces the issue, it seems like a very specific set of circumstances that causes it, I create prefabA at runtime on a button press, this prefabA has a script which creates prefabB in Start(), prefabB then creates another AnimatingImage prefab in Start(), the image flickers on before entering its default animation state which sets the alpha to 0. If I move the prefab creations into Awake() the bug goes away, if I remove a layer of creation of prefabs it also goes away.

    It's not exactly how we do it in game, we have our prefabs created on animation events but we require a fairly complex setup of prefabs due to what information is available to us at specific times. I shall create a new bug and attach the SimpleProject.
     
  3. AndyJRussell

    AndyJRussell

    Joined:
    Mar 21, 2016
    Posts:
    8
  4. Pixelome

    Pixelome

    Joined:
    Sep 30, 2014
    Posts:
    11
    I have found this bug in 5.4.3f1.

    It occurs when the animated object is instantiated in response to an animation event. I've reproduced this behavior in a separate project.

    My workaround is to wait until the next frame to insatiate the object. I did this with a coroutine:

    Code (CSharp):
    1. public void AnimationEvent () {
    2.      // instantiation here causes first frame glitch
    3.     StartCoroutine(DispatchAnimationEvent());
    4. }
    5.  
    6. IEnumerator DispatchAnimationEvent () {
    7.     yield return new WaitForEndOfFrame();
    8.     // safe to instantiate
    9. }
    I hope this helps someone, and it gets fixed in a future version :)
     
    ovoemail likes this.
  5. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,277
    Could you submit a bug report with this information please? Thanks
     
  6. Pixelome

    Pixelome

    Joined:
    Sep 30, 2014
    Posts:
    11
    I have submitted a bug reported as you asked. Case number 858285.
     
    karl_jones likes this.
  7. juanelo

    juanelo

    Joined:
    Jan 28, 2011
    Posts:
    46
    Any update on this? Using Unity 5.6.0f3 and the issue still persists. Using the animator to enable a child gameobject that contains it's own animator results in the child flashing before proceeding to the first frame of its animation.

    edit:
    Like a prior user suggested, a temporary workaround seems to be to set the child animator's update mode to 'Animate Physics'. Note that if the parent is also set to animate physics, the solution no longer works.
     
    Last edited: May 25, 2017
  8. Pixelome

    Pixelome

    Joined:
    Sep 30, 2014
    Posts:
    11
    This is the response I got from the Unity team:

     
    io-games and CRO_Fr3ak like this.
  9. futurlab_peterh

    futurlab_peterh

    Joined:
    Jan 23, 2018
    Posts:
    38
    Same issue happens if the prefab is instantiated as a response to a received network message (such as a RPC invocation). The animator.Update(0) is also a valid workaround in this case.
     
  10. mahdiii

    mahdiii

    Joined:
    Oct 30, 2014
    Posts:
    856
    I have the problem in unity 2018.2.11f1.
    animator.Update(0) in OnEnable does not solved it.
    I see the previous animation at first and then the current animation.
     
    Last edited: Dec 22, 2018
  11. mahdiii

    mahdiii

    Joined:
    Oct 30, 2014
    Posts:
    856
    I solved it. It was annoying.

    Code (CSharp):
    1.  
    2. _animator.Update(0);
    3. _skeletonAnimator.Update();