Search Unity

Bug with the Write Defaults?

Discussion in 'Animation' started by Schminitz, Mar 27, 2015.

  1. Schminitz

    Schminitz

    Joined:
    Nov 15, 2013
    Posts:
    16
    Hello,

    I recently upgrade my project to unity 5, and I was hoping that the 'Write Defaults' property on an animation state would help me.

    But it seems bugged, or it does not work like I was expecting it.

    Let me explain my problem:

    I have a component that is initaly disabled on my object (let's say BoxCollider2D)

    During an animation state (Attack), I enable BoxCollider2D, and at the end of this animation state, I disable it (so his initial value).

    But if I interrupt my Attack (in the middle of the animation, when BoxCollider2D is active) to go back to my Idle animation state (via a trigger for example), the BoxCollider2D will not return to 'disabled'.

    No matter if I check or not 'Write Defaults' on my Idle animation state.

    Am I missing something? Isn't it supposed to reset values of animated properties?

    If not, do you know a way to do what I want to do? Without resetting manually all the properties into the 'Idle' state?
     
  2. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    Hi Schminitz,

    Does your Attack animation animated the BoxCollider2D.enable or you are using a SMB to change the value of this properties?

    If the properties is animated then yes it look like a bug, in this case can you please log a bug?
     
  3. Schminitz

    Schminitz

    Joined:
    Nov 15, 2013
    Posts:
    16
    Hi, thanx for replying

    The BoxCollider2D.enable is changed by the animation.

    I will report a Bug then.

    Thank you
     
  4. Schminitz

    Schminitz

    Joined:
    Nov 15, 2013
    Posts:
    16
    While I was preparing a project to reproduce the bug, I found that the problem wasnt really what I described before.

    Just before I reset my animation, I deactivate / activate my gameobject to force the OnDisable() of all component to be executed. I guess it's not a good idea, that is what provoked the bug.

    // This will reset all components
    gameObject.SetActive (false);
    gameObject.SetActive (true);

    anim.SetTrigger("Reset");
     
  5. Orion

    Orion

    Joined:
    Mar 31, 2008
    Posts:
    261
    Hm. I'm not doing that and still have the same problem. As soon as an animation is in the animator that changes the value, the value gets overridden with default (even if I never enter the animation state).
     
  6. Schminitz

    Schminitz

    Joined:
    Nov 15, 2013
    Posts:
    16
    I'm not sure I do understand you usecase. But did you try to uncheck 'Write defaults' ?
    When I read your post, it looks like you have the opposite behavior than my initial problem.
     
  7. Orion

    Orion

    Joined:
    Mar 31, 2008
    Posts:
    261
    Sorry, you're right. I did indeed just realize that I misinterpreted your post and do have the opposite case. My property keeps getting overwritten with default, no matter which animation is playing and no matter if I check write defaults or not.