CoreAnimGraph is responsible for dynamically playing animations and poses from code, as well as for curve-blending.
Think of it as an extension for the Unity Animator, where you can play animations right from code.
CoreAnimGraph is based on AnimationLayerMixerPlayable's and a custom CoreAnimMixer playables. The structure of the whole graph is this:
Unity Animator - pose from your animator controller.
Overlay Poses - animation mixer, that blends static poses. Static poses are important for the proper IK placement and blending with dynamic animations.
Dynamic Animations - any motion played from code via the PlayAnimation() method.
Methods and properties
CoreAnimGraph.cs
// Called when a character is instantiated or initialized.publicboolInitPlayableGraph()// Called every frame to update the mixers and weights.public void UpdateGraph()// Returns spine root rotation for this animation.public Quaternion GetSpineOffset()// Returns the curve value of the CoreAnimGraph, not the Animator (!!!).// CoreAnimGraph has its own system for curve blending.public float GetCurveValue(string curveName)// Returns the blending progress of the static pose.public float GetPoseProgress()// Sets the graphWeight.public void SetGraphWeight(float weight)// Plays a static pose.public void PlayPose(AnimationClip clip,float blendIn,float playRate =1f)// Plays a dynamic animation.public void PlayAnimation(AnimationClip clip,AnimTime blendTime,Quaternion spineRot,AnimCurve[] curves =null)// Stops currently playing animation.public void StopAnimation(float blendTime)// Returns if graph is playing.public bool IsPlaying()// Updates all mixers weights.public void UpdateGraphWeights()// Plays the first frame of the clip on the character.public void SamplePose(AnimationClip clip)public AvatarMask GetUpperBodyMask()// Starts in-editor preiview.public void StartPreview()// Stops in-editor preiview.public void StopPreview()
CoreAnimGraph.cs
// If 1 - the graph is fully enabled, if 0 - disabled.publicfloat graphWeight;// What bones will be animated by static poses and animations.[SerializeField] privateAvatarMask upperBodyMask;// Max amount of blending animations or poses.[Tooltip("Max blending poses")] privateint maxPoseCount =3;[Tooltip("Max blending clips")] privateint maxAnimCount =3;