KybernetikGames / animancer

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

Sample an animation clip and apply to an animancer layer? #348

Closed kodra-dev closed 3 months ago

kodra-dev commented 3 months ago

I've run into this issue: https://forum.unity.com/threads/how-to-sample-pose-directly-from-an-animationclip.721160/

Basically what I need is Unity's AnimationClip.SampleAnimation, however applying the sampled data to a layer, not the whole gameObject, so that I can mix two samples.

The OP of that Unity forum thread said they eventually decided to use Animancer... which is great, but even with Animancer I still don't know how to do it.

KybernetikGames commented 3 months ago

The Playing in Edit Mode page explains how you can use EditModeSampleAnimation for a single animation, so you'll need to make a method like that which takes multiple animations and sets them up in the layers you want.

kodra-dev commented 3 months ago

The only way I know to use layer is like this:

animancer.Layers[index].Play(clip);

I know animancer.Layers[1].Play(clip); actually work in edit mode, but it will cause the whole playable graph to be initialized and the that brings other issues... I'd just like to sample a frame, like EditModeSampleAnimation or Unity's AnimationClip.SampleAnimation, but mixed with layers (or at least with AvatarMask). I still can't figure out how to:

takes multiple animations and sets them up in the layers you want.

KybernetikGames commented 3 months ago

The method I was thinking of is actually EditModePlay rather than EditModeSampleAnimation.

but it will cause the whole playable graph to be initialized

Yeah, then you can just pause or destroy the graph after you evaluate it.