Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

(Poll) Animator locks every property from every Animation state.

Discussion in 'Animation' started by dasgandlaf, Mar 26, 2022.

?

Should Animator lock every property, used in every animation state, even currently unused ones?

This poll will close on Jun 26, 2105 at 6:38 PM.
  1. I prefer the Animator to lock even unused properties.

    0 vote(s)
    0.0%
  2. Only lock properties that are currently under use.

    65.2%
  3. I do not want the Animator to lock any properies.

    13.0%
  4. I extremely dislike the current behaviour (Locking properties), I want it to be changed.

    21.7%
  5. I do not care.

    0 vote(s)
    0.0%
  1. dasgandlaf

    dasgandlaf

    Joined:
    Aug 13, 2020
    Posts:
    23
    Currently, if there are any animation clips inside the Animator, every single property that is used in every Animation clip are locked. Even if they are not used.
    Mecanim-Dev (Unity dev) suggested to use LateUpdate(), when trying to modify properties that are used in animation clips, but this did not work for many, including me. I do not know why it doesn't work.
    The thread:
    https://forum.unity.com/threads/ani...rves-keys-for-that-value.440363/#post-2848316

    Poll to show the devs, what you prefer.
     
  2. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,486
    The reason it works like that is for consistency. If you go through states A, B, and C then store C and either load it back later on from a save file or send it over the network to another computer, the developers of Mecanim wanted it so that playing C would always give the exact same result (assuming the same Animator Controller and animations).

    I've seen cases where that behaviour is unhelpful so I'd like an option to disable it for a specific Animator, but removing it entirely would be bad.

    Also, "I do not want the Animator to lock any properies." makes no sense. The Animator doesn't "lock" anything, it writes values from the animation data to the animated fields every frame. If it didn't write values then it would be doing literally nothing and the system wouldn't work. Most likely you misunderstood this when trying to use LateUpdate. If you only change the value once in LateUpdate, it will get replaced by the animation system the very next frame, so you need to apply your modification every LateUpdate if you want it to stay in effect.
     
  3. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,002
    It doesn’t matter, they are not going to change it. Animator is a collection of asinine design choices and is a pain to use.
     
    Kybernetik likes this.
  4. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,486
    That too, and this particular mechanic is even present in the Playables API which lets you get away from most of the other nonsense of Animator Controllers.

    The documentation of Unity's Simple Animation Component had an explanation that if you disconnect a Playable from its parent it would stop writing the values of that animation which would give the behaviour OP wants ... if it worked. Turns out they must have never actually tested that feature because it simply doesn't work. You can delay it from controlling certain parameters by not creating the Playable for the animation that controls them until you need it, but once you've created that Playable the graph will be writing to all the properties controlled by that animation even if you disconnect or destroy the Playable.

    I also find it very unlikely that they'll change it because they're currently working on a completely new animation system for DOTS. I have faith in their ability to screw up yet another animation system, especially with the focus of DOTS being on runtime performance at the cost of flexibility during development.
     
    AcidArrow likes this.
  5. dasgandlaf

    dasgandlaf

    Joined:
    Aug 13, 2020
    Posts:
    23
    This is my answer, if I understand you correctly: It even locks properties that are not currently animated. If the current animation state is empty, but another animation state in the controller modifies that property, even then you can't modify the value.

    Sadly, this seems to be true.
     
  6. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,486
    ...
    No. It doesn't lock anything. It doesn't prevent you from modifying the value. It applies the value from the animation every frame and you can replace that value in LateUpdate before that frame gets rendered.
     
  7. dasgandlaf

    dasgandlaf

    Joined:
    Aug 13, 2020
    Posts:
    23
    Why don't you test it out first?
     
  8. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,486
    In over 10 years of using Unity and writing my own animation system (link in my signature), I've never once had a problem with LateUpdate working exactly as I described.

    If it's not working for you, then there's a near 100% chance that you're doing it wrong.
     
  9. DucaDiMonteSberna

    DucaDiMonteSberna

    Joined:
    Jan 18, 2018
    Posts:
    51