Search Unity

  1. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Let us know a bit about your interests, and if you'd like to become more directly involved. Take our survey!
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

GameObject Disable Resets Animator But Transform Parameters Remain At Interrupted Animation State

Discussion in 'Animation' started by nikulude, Oct 4, 2018.

  1. nikulude

    nikulude

    Joined:
    Nov 29, 2017
    Posts:
    3
    I got the following problem and it really drives me insane - I can not imagine that there is no solution to this,

    Google didn't help me so far so here I am hoping to get help by the community or unity devs:

    I got an enemy represented by a parent object and lets say two child objects, Animator attached on the parent. There are at least two animations in the state machine where rotation and position of child objects are altered - think about moving hands up and down and moves for shooting and jumping. And I am of course using an enemy pool, which means when enemy hit -> disabled, when enemy of same type needed - get it from pool and reenable. So far so good.

    Now imagine the enemy is in the middle of the first animation and gets hit = disabled and stored in the pool. When I reenable him, the Animator is reset but child transforms remain in the state from the middle of the "interrupted" animation, when the enemy was disabled. So in the default state, when hands are not being moved one of the hand is half up, other half down instead both hands down. How to reset the "default" state? Everything reset through script, where all possible child transform parameters like position and rotation are reset to the default values? What is when I have a complex object containing multiple layers and 50 child transforms that are bein altered in animations?!..

    Is there any plausible solution to this (seemingly trivial) problem?

    Thanks!
     
  2. SilentSin

    SilentSin

    Joined:
    Jan 3, 2013
    Posts:
    82
    I submitted a bug report about something similar - specifically, the ways this behaviour is different from the Playables API and how neither system gets it quite right. That was almost half a year ago and I haven't heard anything after the initial "yep that's a bug".

    There's also this thread which doesn't really have a solution either: https://forum.unity.com/threads/write-defaults-confusion-bug.392058/.

    The only way I found to ensure the models are properly reset for pooling is to use my Animancer plugin (or presumably anything using the Playables API) and manually call StopAll then Evaluate before deactivating the object. It can't be automated in OnDisable, it has to be before the actual SetActive(false) call. And trying to do the same thing in Mecanim had no effect.

    That was in 2018.1 and I have no idea if this behaviour has been fixed or altered since then.