KybernetikGames / animancer

Documentation for the Animancer Unity Plugin.
65 stars 8 forks source link

Using unity's Animation rigging package #304

Closed The-Ash closed 1 year ago

The-Ash commented 1 year ago

Saw the documentation page on the subject https://kybernetik.com.au/animancer/docs/examples/integration/animation-rigging/

But i'm still confused about how the second workaround option should look like: I tried just rebinding after every animation but it doesn't seem to work. Storing and re-applying constrains is a must? which ones need to be stored? Is it possible that i'm missing something else?

Maybe there is a code example i can see to understand how it's supposed to look?

KybernetikGames commented 1 year ago

Storing and re-applying constrains is a must?

Yes, just rebinding won't help. Rebinding forces the reset to occur immediately so if you've already stored the values you can re-apply them right afterwards. Otherwise you would need to store the values, let the animation system update where it will do the rebind, then in LateUpdate you re-apply the values, which would achieve the same thing but would just be more complex to manage.

which ones need to be stored?

Any values that are being reset which you don't want to reset. The values that are relevant to you will depend entirely on what's in your rig.

For example, if you have a constraint weight that you don't want to reset, you would do this:

var weight = constraint.weight;// Store.
animancerComponent.Animator.Rebind();// Rebind.
constraint.weight = weight;// Re-apply.