Debugging

Animation management is a fairly complex subject which unfortunately means there are a wide variety of different problems that you might encounter when working with them, so this page explains how to identify and resolve them.

Logging

Using an IDE like Visual Studio allows you to use it's Debugger to pause the game and step through your code (and Animancer's internals if you have Animancer Pro) line by line to see exactly what is happening and examine the values of any variables. Debuggers can be extremely useful for finding the cause of a bug, but they are not necessarily ideal for all situations and are sometimes not usable at all. For example, when debugging a networked multiplayer game you can't simply let the debugger pause the game on one computer because the others would think it has disconnected. There are also times when you don't know exactly what is causing a bug so you don't know when it would need to be paused.

If you can't or don't want to use a debugger, you can use various methods in Unity's Debug class to log messages to record things that happen and important values:

  • In the Unity Editor, log messages are displayed in the Console window.
  • In a Runtime Build, log messages are saved into a Log File.
  • Note that logging can have a notable performance cost which is not automatically removed from Runtime Builds, so you should be careful with unnecessary logging.

For example, if you want to find out which animation is currently being played you could simply log it like so:

private void LogCurrentAnimation(AnimancerComponent animancer)
{
    Debug.Log(animancer.States.Current);
}

Or if you want to log the full details of a state, you can use the GetDescription methods:

Debug.Log(animancer.States.Current.GetDescription());// Description of current state.
Debug.Log(animancer.Playable.GetDescription());// Description of all states.

You can also manually log those messages using Context Menu functions.

Inspector

In Play Mode, you can select an object with an AnimancerComponent and use the Inspector to examine the current Details of all the states it manages in real-time.

Rig Types

If a character with a Generic Rig is not playing any animation it will simply not move, but if a Humanoid Rig is not playing any animation it will go into a "compressed" or "hunched over" pose according to the muscle limits defined in the Avatar configuration (pictured to the right). One of the most common reasons for this to happen is if you accidentally try to play a Generic animation on a Humanoid Rig (or vice-versa). Both the model and animations must use the same Rig type.

The Animation Types section explains the potential incompatabilities between models and animations in more detail.

Other

  • If an animation is not playing properly, it may be worth trying it in a regular Animator Controller to determine whether the problem is caused by Animancer or something else.
  • If you encounter an issue that only occurs in runtime builds, you can enable the Development Build option in the Build Settings window so that Animancer will include various debug assertions (additional error checking with more descriptive messages) which are normally only active in the Unity Editor.
  • If you think there may be a bug relating to the ObjectPool system, you can make it log various usage events by going to Edit -> Project Settings -> Player -> Other Settings -> Scripting Define Symbols and adding ANIMANCER_LOG_OBJECT_POOLING to that field. This only works with Animancer Pro.

If you still can't track down the cause of a problem, the Help page lists several contact methods you can use to get help with your specific issue.