Skip to content

AnimationPlayer Component ​

AnimationClipをGroupとStateへ登録し、プロパティAnimationを再生します。

設定する手順 ​

  1. Clipを作成してGroupに登録し、初期Groupと再生開始を設定します。
  2. SceneViewまたはGameViewで結果を確認します。
  3. 編集中のSceneまたはPrefabを保存します。

項目の説明 ​

項目C#名型操作定義時の初期値意味
有効enabledbool読取・変更trueこのComponentの処理を有効にします。GameObject全体のアクティブ状態とは別です。
全体速度speedfloat読取・変更1.0f全GroupのAnimation時刻に掛ける再生倍率です。
CurrentGroupCurrentGroupstring読取専用追加時の設定を参照現在再生中のGroup名です。
IsPlayingValueIsPlayingValuebool読取専用false再生中かを取得します。
FinishedFinishedbool読取専用false再生完了状態を取得します。
PlayRequestPlayRequeststring読取・変更追加時の設定を参照次の更新で再生するGroup名を要求します。
PlayFadePlayFadefloat読取・変更0.0f再生切替時のフェード秒数です。
RepeatCountRepeatCountint読取専用0現在の繰り返し回数です。
StopRequestStopRequestbool読取・変更false停止を要求します。
DirectClipRequestDirectClipRequestAnimationClip?読取・変更{}Groupを経由せず再生するClip参照です。
NormalizedFadeNormalizedFadebool読取・変更falseフェード時間を正規化した値として扱うかを指定します。
NormalizedOffsetNormalizedOffsetbool読取・変更true開始位置を0〜1の正規化時間として扱うかを指定します。
PlaybackTimeRequestPlaybackTimeRequestfloat読取・変更-std::numeric_limits<float>::infinity()再生またはSeekに使う時刻です。
SeekRequestSeekRequestbool読取・変更false指定時刻への移動を要求します。
NormalizedTimeValueNormalizedTimeValuefloat読取専用0.0f現在のClip内時刻を0〜1で表した値です。
ClipDurationClipDurationfloat読取専用0.0f現在のClipの長さです。単位は秒です。
LoopingLoopingbool読取専用false現在の再生がループするかを取得します。
開始グループDefaultGroupstring読取・変更追加時の設定を参照再生開始時に選ばれるGroup名です。
開始時に再生PlayOnStartbool読取・変更truePlay開始時に自動再生します。

Inspectorの設定と使い方 ​

「Editor / C#」は両方から変更できる設定、「Editorのみ」は公開C# APIのない編集操作です。「Editor表示のみ」は計算結果や統計などの確認欄です。「C#のみ」は、このInspectorに編集欄のない操作です。

設定・操作編集場所C#の入口意味・使い方
有効・開始時再生・全体速度・開始グループEditor / C#enabled / PlayOnStart / speed / DefaultGroupC#の操作型はAnimatorです。保存したグループを名前で再生し、全体速度を個々のStateの速度へ掛けます。
グループ・State・Clip・weight・優先度Editor / C#GetGroups / SetGroupsStateごとのClip、再生速度、weight、優先度、Additive、向き相対、開始遅延を設定します。設定を取得して編集した後はSetGroupsで反映します。
ループ形式・回数・インターバル・繋ぎ補間Editor / C#GetGroups / SetGroups一度だけ・ループ・往復などの再生形式をStateに設定します。ループの繋ぎ補間は終端から次の開始までの補間で、回数や待機時間とは別です。
編集中に再生Editorのみ—Play前にClipの見た目を確認する設定です。現在のAnimatorの公開C# APIに対応するPreview用プロパティはありません。
Play・PlayClip・CrossFade・Seek・StopC#のみPlay / PlayClip / CrossFade / CrossFadeInFixedTime / Seek / StopState名での再生、Clipの直接再生、遷移、再生位置指定、停止に使います。CrossFadeの遷移量は正規化値、CrossFadeInFixedTimeは秒指定なので引数を取り違えないでください。

初期値はEngineのComponent定義時の値で、C++表記を含みます。C#へ貼り付ける実行例ではありません。既存Sceneの保存値や既定Assetがある場合はそちらが優先されます。数値の編集範囲はInspectorで制限される場合があります。

C#から使う ​

操作型はAnimatorです。 GameObjectから取得する基本操作はGameObjectの操作を参照してください。以下には基本プロパティだけでなく、公開関数・追加の設定API・継承した共通操作も掲載します。

実用例:操作に応じて作成済みのStateを再生する ​

AnimationPlayerへグループとStateを用意し、stateNameを存在するState名へ合わせます。C#ではAnimatorを取得します。

cs
using NEMEngine;

public sealed class ActionAnimation : MonoBehaviour {

    [SerializeField] private string stateName = "Attack";
    private Animator? animator;

    void Start() {
        // AnimationPlayerのC#操作型を取得
        animator = GetComponent<Animator>();
    }

    void Update() {
        // 入力に応じて、Editorで設定したStateを再生
        if (animator != null && Input.GetKeyDown(KeyCode.E)) animator.Play(stateName);
    }
}

設定用・関連するC#型 ​

Animator ​

宣言・詳説種類・操作役割
public float ClipDurationプロパティ(読取専用)現在のClipの長さです。単位は秒です。
public void CrossFade(string stateName, float normalizedTransitionDuration, int layer = -1, float normalizedTimeOffset = -Infinity)関数指定した再生へフェードで切り替えます。
public void CrossFadeInFixedTime(string stateName, float fixedTransitionDuration, int layer = -1, float fixedTimeOffset = 0)関数フェード秒数を指定してAnimation Groupを切り替えます。
public string CurrentGroupプロパティ(読取専用)現在再生中のGroup名です。
public string DefaultGroupプロパティ(読取・変更)再生開始時に選ばれるGroup名です。
public AnimationClip? DirectClipRequestプロパティ(読取・変更)Groupを経由せず再生するClip参照です。
public bool Finishedプロパティ(読取専用)再生完了状態を取得します。
public static Animator FromEntity(GameObject gameObject)関数既にComponentを持つGameObjectから操作用の参照を作ります。Componentを追加する操作ではありません。
public AnimatorStateInfo GetCurrentAnimatorStateInfo(int layerIndex)関数現在のAnimation再生時刻やGroup名を取得します。
public IReadOnlyList<AnimationGroupSettings> GetGroups()関数GroupとStateの設定Snapshotを取得します。
public bool IsPlayingプロパティ(読取専用)指定名のAnimationなどが再生中かを調べます。
public bool IsPlayingValueプロパティ(読取専用)再生中かを取得します。
public bool Loopingプロパティ(読取専用)現在の再生がループするかを取得します。
public bool NormalizedFadeプロパティ(読取・変更)フェード時間を正規化した値として扱うかを指定します。
public bool NormalizedOffsetプロパティ(読取・変更)開始位置を0〜1の正規化時間として扱うかを指定します。
public float NormalizedTimeValueプロパティ(読取専用)現在のClip内時刻を0〜1で表した値です。
public void Play(string stateName, int layer = -1, float normalizedTime = -Infinity)関数指定した再生を開始または再開します。
public void PlayClip(AnimationClip clip, float normalizedTime = 0)関数保存済みグループを変更せずに単独Clipを再生
public float PlayFadeプロパティ(読取・変更)再生切替時のフェード秒数です。
public bool PlayOnStartプロパティ(読取・変更)Play開始時に自動再生します。
public string PlayRequestプロパティ(読取・変更)次の更新で再生するGroup名を要求します。
public float PlaybackTimeRequestプロパティ(読取・変更)再生またはSeekに使う時刻です。
public int RepeatCountプロパティ(読取専用)現在の繰り返し回数です。
public void Seek(float normalizedTime)関数移動した区間のAnimation Eventは発火しない
public bool SeekRequestプロパティ(読取・変更)指定時刻への移動を要求します。
public void SetGroups(IEnumerable<AnimationGroupSettings> groups)関数編集したGroup一覧をAnimatorへ反映します。
public void Stop()関数再生を停止します。Particleでは既存粒子を残すかも引数で選べます。
public bool StopRequestプロパティ(読取・変更)停止を要求します。
public static int componentTypeIDプロパティ(読取専用)組み込みComponentの接続識別子です。通常のゲームコードではGetComponentで取得します。
public bool enabledプロパティ(読取・変更)このComponentの処理を有効にします。GameObject全体のアクティブ状態とは別です。
public float speedプロパティ(読取・変更)全GroupのAnimation時刻に掛ける再生倍率です。

継承する共通操作:Component ​

宣言・詳説種類・操作役割
public T AddComponent<T>() where T : Component関数ComponentまたはScriptを追加し、操作する参照を返します。
public T? GetComponent<T>() where T : class関数component access(owner GameObjectへの委譲)
public T? GetComponentInChildren<T>(bool includeInactive = false) where T : class関数子階層から指定型のComponentを探します。
public T? GetComponentInParent<T>(bool includeInactive = false) where T : class関数親階層から指定型のComponentを探します。
public T[] GetComponents<T>() where T : class関数同じGameObjectにある指定型のComponentをすべて取得します。
public void GetComponents<T>(List<T> results) where T : class関数同じGameObjectにある指定型のComponentをすべて取得します。
public T[] GetComponentsInChildren<T>(bool includeInactive = false) where T : class関数子階層にある指定型のComponentを収集します。
public void GetComponentsInChildren<T>(bool includeInactive, List<T> results) where T : class関数子階層にある指定型のComponentを収集します。
public void GetComponentsInChildren<T>(List<T> results) where T : class関数子階層にある指定型のComponentを収集します。
public T[] GetComponentsInParent<T>(bool includeInactive = false) where T : class関数親階層にある指定型のComponentを収集します。
public void GetComponentsInParent<T>(bool includeInactive, List<T> results) where T : class関数親階層にある指定型のComponentを収集します。
public override int GetHashCode()関数同じ値を検索Keyに使うためのHashを返します。
public bool HasComponent<T>() where T : class関数指定型のComponentを持つかを調べます。
public void RemoveComponent<T>() where T : Component関数指定型のComponentを取り除きます。
public bool TryGetComponent<T>(out T component) where T : class関数Componentを検索し、見つかったかをbool、結果をout引数で返します。
public GameObject gameObjectプロパティ(読取専用)このComponentを所有するGameObjectです。
public Transform transformプロパティ(読取専用)所有GameObjectのTransformです。

継承する共通操作:Object ​

宣言・詳説種類・操作役割
public static void Destroy(Object? target)関数参照先の個体だけを安全地点で破棄する
public override bool Equals(object? obj)関数2つの値が等しいかを調べます。
public override int GetHashCode()関数同じ値を検索Keyに使うためのHashを返します。
public static GameObject Instantiate(Prefab original)関数Prefabまたは指定したGameObject・Componentを複製して参照を返します。生成できない場合は例外です。nullを返す前提で処理しないでください。
public static GameObject Instantiate(Prefab original, GameObject? parent)関数Prefabまたは指定したGameObject・Componentを複製して参照を返します。生成できない場合は例外です。nullを返す前提で処理しないでください。
public static GameObject Instantiate(Prefab original, Vector3 position, Quaternion rotation)関数Prefabまたは指定したGameObject・Componentを複製して参照を返します。生成できない場合は例外です。nullを返す前提で処理しないでください。
public static GameObject Instantiate(Prefab original, Vector3 position, Quaternion rotation, GameObject? parent)関数Prefabまたは指定したGameObject・Componentを複製して参照を返します。生成できない場合は例外です。nullを返す前提で処理しないでください。
public static T Instantiate<T>(T original) where T : Object関数Prefabまたは指定したGameObject・Componentを複製して参照を返します。生成できない場合は例外です。nullを返す前提で処理しないでください。
public static T Instantiate<T>(T original, GameObject? parent) where T : Object関数Prefabまたは指定したGameObject・Componentを複製して参照を返します。生成できない場合は例外です。nullを返す前提で処理しないでください。
public static T Instantiate<T>(T original, Vector3 position, Quaternion rotation) where T : Object関数Prefabまたは指定したGameObject・Componentを複製して参照を返します。生成できない場合は例外です。nullを返す前提で処理しないでください。
public static T Instantiate<T>(T original, Vector3 position, Quaternion rotation, GameObject? parent) where T : Object関数Prefabまたは指定したGameObject・Componentを複製して参照を返します。生成できない場合は例外です。nullを返す前提で処理しないでください。
public static bool operator ==(Object? lhs, Object? rhs)関数等値比較を行います。引数型と戻り値型で、成分ごとの演算か対象参照の比較かを確認してください。
public static implicit operator bool(Object? value)関数暗黙の型変換を行います。引数型と戻り値型で、成分ごとの演算か対象参照の比較かを確認してください。
public static bool operator !=(Object? lhs, Object? rhs)関数不等値比較を行います。引数型と戻り値型で、成分ごとの演算か対象参照の比較かを確認してください。

使用時の注意 ​

C#側の型名はAnimatorです。同じ値を同時に書くClipの競合に注意します。

Play中の変更は実行用Worldへ反映します。Scene編集のUndoと実行中の値の変更は別です。保存方法は編集と実行時変更を参照してください。

関連項目 ​

現行版マニュアル · 8ea58ba2 · 2026-10-28確認