LoginSignup
21
28

More than 5 years have passed since last update.

unityでfbxをアニメーションさせる

Last updated at Posted at 2016-05-19

備忘録

読み込み方・動かし方

  1. アニメーションがついているfbxをAssets 以下に配置。
  2. Assets内で右クリックしてAnimator Controllerを作る。Animator ControllerオブジェクトをダブルクリックするとAnimatorウィンドウ的なやつが出る
  3. fbxの中に再生マークがついたオブジェクトが入っているので、それをAnimatorウィンドウにドロップする。Entryってとこからnodeがつながれる。
  4. fbxをHierarchyにいれるとAnimatorコンポーネントがくっついている。それのControllerって変数に1でつくったAnimator Controllerをリンクさせる

スクリプトでの制御

Animatorウィンドウ内に、いくつかアニメーションを入れ込むと、そのアニメを表す四角ができる。その名前を使ってスクリプトで再生ができる。特にノードをつなぐ必要はなし。

using UnityEngine;
using System.Collections;

public class AnimCtrl : MonoBehaviour {

    Animator anim;

    void Awake () {
        anim = GetComponent<Animator> ();
    }

    void OnGUI () {
        // "run"ボタンが押されたら
        if (GUI.Button (new Rect (20, 10, 80, 20), "run")) {
            anim.CrossFade("run",0);
        }

        // "walk"ボタンが押されたら
        if (GUI.Button (new Rect (20, 30, 80, 20), "walk")) {
            anim.CrossFade("walk",0);
        }
    }


}

もっとちゃんと知りたい方はこちら

21
28
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
21
28