Retargeting of Humanoid animations
Performance and optimization
This page contains some tips to help you obtain the best performance in Unity, covering the animation system and run-time optimizations.
Note: For tips on modeling your character in a 3d application for best performance in Unity, see Modeling characters for optimal performance.
Animation system
Controllers
The Animator doesn’t spend time processing when a Controller is not set to it.
Simple animation
Playing a single Animation ClipAnimation data that can be used for animated characters or simple animations. It is a simple “unit” piece of motion, such as (one specific instance of) “Idle”, “Walk” or “Run”. More info
See in Glossary with no blending can make Unity slower than the legacy animation system. The old system is very direct, sampling the curve and directly writing into the transform. Unity’s current animation system has temporary buffers it uses for blending, and there is additional copying of the sampled curve and other data. The current system layout is optimized for animation blending and more complex setups.
Scale curves
Animating scale curves is more expensive than animating translation and rotation curves. To improve performance, avoid scale animations.
Note: This does not apply to constant curves (curves that have the same value for the length of the animation clip). Constant curves are optimized, and are less expensive that normal curves. Constant curves that have the same values as the default sceneA Scene contains the environments and menus of your game. Think of each unique Scene file as a unique level. In each Scene, you place your environments, obstacles, and decorations, essentially designing and building your game in pieces. More info
See in Glossary values do not write to the scene every frame.
Layers
Most of the time Unity is evaluating animations, and keeps the overhead for animation layersAn Animation Layer contains an Animation State Machine that controls animations of a model or part of it. An example of this is if you have a full-body layer for walking or jumping and a higher layer for upper-body motions such as throwing an object or shooting. The higher layers take precedence for the body parts they control. More info
See in Glossary and Animation State MachinesA graph within an Animator Controller that controls the interaction of Animation States. Each state references an Animation Blend Tree or a single Animation Clip. More info
See in Glossary to the minimum. The cost of adding another layer to the animator, synchronized or not, depends on what animations and blend trees are played by the layer. When the weight of the layer is zero, Unity skips the layer update.
Humanoid vs. Generic animation types
These are tips to help you decide between these types:
- When importing Humanoid animationAn animation using humanoid skeletons. Humanoid models generally have the same basic structure, representing the major articulate parts of the body, head and limbs. This makes it easy to map animations from one humanoid skeleton to another, allowing retargeting and inverse kinematics. More info
See in Glossary use an Avatar MaskA specification for which body parts to include or exclude for an animation rig. Used in Animation Layers and in the importer. More info
See in Glossary (class-AvatarMask) to remove IK Goals or finger animation if you don’t need them.
- When you use Generic, using root motionMotion of character’s root node, whether it’s controlled by the animation itself or externally. More info
See in Glossary is more expensive than not using it. If your animations don’t use root motion, make sure that you have not specified a root bone.
Scene-level optimization
There are many optimizations that can be made, some useful tips include:
- Use hashes instead of strings to query the Animator.
- Implement a small AI Layer to control the Animator. You can make it provide simple callbacks for OnStateChange, OnTransitionBegin, and other events.
- Use State Tags to easily match your AI state machineThe set of states in an Animator Controller that a character or animated GameObject can be in, along with a set of transitions between those states and a variable to remember the current state. The states available will depend on the type of gameplay, but typical states include things like idling, walking, running and jumping. More info
See in Glossary to the Unity state machine.
- Use additional curves to simulate events.
- Use additional curves to mark up your animations; for example, in conjunction with target matchingA scripting function that allows you to move characters in such a way that a hand or foot lands in a certain place at a certain time. For example, the character may need to jump across stepping stones or jump and grab an overhead beam. More info
See in Glossary.
Runtime Optimizations
Visibility and updates
Always optimize animations by setting the animators’s Culling Mode to Based on Renderers, and disable the skinned mesh renderer’s Update When Offscreen property. This saves Unity from updating animations when the character is not visible.
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Is something described here not working as you expect it to? It might be a Known Issue. Please check with the Issue Tracker at issuetracker.unity3d.com.
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thanks for helping to make the Unity documentation better!
Retargeting of Humanoid animations