Search Unity

Stop states from resetting once animation changes?

Discussion in 'Animation' started by NeilM0, Feb 10, 2015.

  1. NeilM0

    NeilM0

    Joined:
    Mar 31, 2009
    Posts:
    135
    I've been hitting this issue with the animation engine and simplified it down to this basic problem that I was wondering if anyone had a solution to.

    - I created a scene with two UI panels.
    - There are two animations linked with an exit transition set to 1.0. The initial animation turns panel 1 on, and panel 2 off.
    - When the initial animation is done, it moves on to animation 2 which doesn't do anything, except loop.

    What I expected to see was no visible change. Panel 1 is on and Panel 2 is off. What I actually see is both panels turn on. Is there any way to get the animation engine to leave things as they are when it exits an animation?
     

    Attached Files:

  2. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    By default, when the animation engine detect that an animated property is not animated in a clip, the engine write the default value in this property.

    In 4.6 and 5.0 we did add a new member called Write Defaults on an Animator State, by default this value is true.
    This new member control if the engine should write or not default value on property not animated by any clip while evaluating this state.
     
  3. Gizmoi

    Gizmoi

    Joined:
    Jan 9, 2013
    Posts:
    327
    Your explanation seems unclear to me. Should this new Write Defaults setting be disabled if we want things to be left as they are upon exiting a state?
     
  4. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    yes exactly

    If a state's clip is not animating a property, if you don't want this state to reset this property to the default value you need to uncheck WriteDefaults on this state.
     
    dreamer- likes this.
  5. Arttut

    Arttut

    Joined:
    May 27, 2014
    Posts:
    4
    I have v. 4.6 (free), but can't find the option from the Animator State..
     
  6. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    You are right, it was added in 5.0

    Sorry :confused:
     
  7. runestonegames

    runestonegames

    Joined:
    Dec 16, 2014
    Posts:
    98
    I have a similar problem that is not fixed by un-checking WriteDefaults. What I need to do is change to another animation state, and then change the value of a property using code, whilst the animation is still running.

    1. With WriteDefaults = true, the animator will overwrite a property with the 'default' value.
    2. With WriteDefaults = false, the animator will overwrite a property it's value at the time the animation state is entered.

    What I could like, and I feel would be more useful, is for the animator to just leave the property untouched - for the duration of the animation. Surely, this would make the greatest amount of sense?