Search Unity

Resolved Animation created at runtime does not run in standalone

Discussion in 'Scripting' started by Donsky, Nov 14, 2020.

  1. Donsky

    Donsky

    Joined:
    Mar 27, 2014
    Posts:
    80
    Hello, I've run into the following issue: I have a script that overrides a bunch of animations when the character performs some action. AnimatorController is layered and has logic layer (firing animation events), as well as several other layers for actual bone transform. Logic layer is generated procedurally at runtime and everything works as intended inside the Editor. Once I make a standalone build and run it, for some bizarre reason, the events don't fire any more... Can anyone suggest, what's happening here?

    PS: Events initially had MonoBehaviour type parameters, then I changed them to integers for testing, but the problem is still present.
     
  2. Donsky

    Donsky

    Joined:
    Mar 27, 2014
    Posts:
    80
    I initially suspected that the issue had something to do with not being able to find the callback function, so I arbitrarily added a root scale animation curve and a rebind to the whole thing, but I still get the same: Works just fine in editor, but the standalone version will just 'refuse' to run the animation for some reason (in editor, rebind is necessary for scale to work and state machine acts not as intended, but is still working well enough for the effect to be obvious)

    Note: I've experimented with 'debug/release/master' builds, as well as Mono/IL2cpp, nothing works; Added a rather predictable behavior in some functions to make sure the overrides are set correctly and they indeed are, but the animator seemingly ignores the override clip that was created dynamically; Next step for me is to create an asset with a custom editor, that procedurally generates a static animation asset, but since that takes away much of the simplicity on the designer's side, as well as adds an amount of complexity to the code, I kind of wish there was a better solution...
     
  3. Donsky

    Donsky

    Joined:
    Mar 27, 2014
    Posts:
    80
    Probably, Unity is just not OK with standalone creating runtime clips and using them in mechanim state machine... "Solved" by generating those animations statically and adding lookups instead of direct references