I’m currently looking into options to override a specific clip on my Animators at runtime. Looking through the documentation, I found this page detailing how to create an Animator Override Controller at runtime and swap it in to replace a clip. This works great, however the issue is that the Animator I am trying to replace a clip on is itself already using an Animator Override Controller.
When retrieving animator.runtimeAnimatorController in order to initialize my new Animator Override Controller at runtime, it retrieves the base Animator Controller, not the Override that’s currently on the Animator. As a result, my new Animator Override Controller does not know about any of the overridden clips that the original Override Controller had, and instead just plays the base animations.
What I have been able to do in the interim is give my script a reference to the base Override Controller used by my Animator, and when initializing the new one at runtime, I call GetOverrides on the original and pass them to the new one with ApplyOverrides. This solves the problem, passing along any overrides I was using to the new Override Controller, while then including the new clips overridden at runtime.
However, this requires that reference to the base Animator Override Controller. If possible, I would ideally like to be able to grab it directly from the Animator in order to avoid any human error when setting things up, however I have been unable to find any way to do this.
Is there any way to retrieve an Animator Override Controller that is on an Animator at runtime? So far my searches online and through the documentation haven’t yielded any results.
Thanks!