GAME USE

Playing anim files during game development

This guide shows how to test a downloaded anim pose in Unity's Game view.

Unity Game view showing an anim pose played during game testing
Call an anim State in Game view

Register the anim clip as a State in an Animator Controller first, then call that State from a MonoBehaviour Script. This keeps the test small and easy to debug.

Before you start

This article starts from the point where your anim file is already registered in an Animator Controller. If you are not sure where to put the Controller or the anim clip, read Basic checks when importing anim files into Unity first.

  • The anim clip is registered as a State in an Animator Controller
  • The avatar or target object has an Animator component
  • You have a test Scene ready for checking the pose in Game view

1. Create the script

Right-click an empty area in Assets and choose Create > Scripting > MonoBehaviour Script. Some Unity versions may show this as a C# Script.

Unity screen showing Create, Scripting, and MonoBehaviour Script from the Assets context menu

In this example the script is named PlayAnimExample. Any clear name is fine as long as you can tell it is for testing animation playback.

using UnityEngine;

public class PlayAnimExample : MonoBehaviour
{
    [Header("Animator")]
    [SerializeField] private Animator animator;

    [Header("Animation State Name")]
    [SerializeField] private string animationStateName = "Milltina_Free_01";

    private void Start()
    {
        PlayAnimation();
    }

    public void PlayAnimation()
    {
        if (animator == null)
        {
            Debug.LogError("Animator is not assigned.");
            return;
        }

        animator.Play(animationStateName, 0, 0f);
    }
}

animator.Play(animationStateName, 0, 0f); plays the named State on layer 0 from the beginning. For pose checks, starting from the first frame is usually the easiest behavior to read.

2. Attach it to an empty object

In the Hierarchy, press Control + Shift + N to create an empty GameObject. A name like Script or PlayAnimExample is fine.

Drag the script onto that empty object. Keeping test logic on a separate object makes it easy to remove or replace later, instead of mixing temporary code into the avatar itself.

Unity screen showing an empty object in the Hierarchy with the script dragged onto it

3. Assign the Animator and State name

Select the empty object and look at the script fields in the Inspector. Drag the target avatar's Animator into the Animator field.

Then enter the Animator State name into Animation State Name. In the example, the State name is Milltina_Free_01. By default, the anim file name often becomes the State name, but if the State has been renamed, use the State name visible in the Animator window.

Unity screen showing the Play button and Game view pose playback

If one character is different, the State will not play. When in doubt, copy the State name from Animator and paste it into the Inspector field.

4. Press Play and check Game view

Press the Play button at the top of Unity. Check the result in Game view, not only Scene view.

Unity Inspector showing the Animator field and animation State name field

This sample calls PlayAnimation() from Start(), so the pose plays as soon as Play Mode begins. Later, you can call the same method from a UI button, click event, trigger area, or another gameplay script.

If it does not work

The pose does not change

The Animator field may be empty, or it may point to the wrong object. Assign the Animator that controls the full avatar or target object.

The Console shows an error

If you see Animator is not assigned., the Inspector field has not been filled in yet. Assign the Animator first.

The State name does not play

Check that the State name in the Animator Controller matches the text in the Inspector. If the State is on another layer, update the layer index in the script as well.

How to expand this for an actual game

First confirm that the script can play one State cleanly. After that, connect PlayAnimation() to the gameplay trigger you actually need: a button, a collider, a dialogue event, or a stage sequence.

References

Unity screen showing how to create an Animator Controller Basic checks when importing anim files into Unity UNITY / 2026.05.08 Unity screen showing required prefabs added to the Hierarchy Required Prefabs for setup PREFAB / 2026.05.08 Unity Animation tab previewing facial expression clips Fixing broken facial expressions on edited avatars FACE EMOTE / 2026.05.09
Back to Tips