22
Mecanim on Unity 4.3 実例による新機能の紹介 2013/12/08 森本陽介

Mecanim on Unity 4.3 実例による新機能の紹介

Embed Size (px)

DESCRIPTION

3Dパズルゲーム「二人の漸近線」の制作を通して、 ・Mecanimの機能をどう活用したか ・Unity 4.3でどこが便利になったか を紹介しています。

Citation preview

Page 1: Mecanim on Unity 4.3 実例による新機能の紹介

Mecanim on Unity 4.3 !実例による新機能の紹介

2013/12/08 森本陽介

Page 2: Mecanim on Unity 4.3 実例による新機能の紹介

自己紹介

森本陽介

九州大学芸術工学部

卒論やばいです@YosukeM

Page 3: Mecanim on Unity 4.3 実例による新機能の紹介

二人の漸近線(制作中)

http://www.facebook.com/throbofencounters

http://www.facebook.com/throbofencounters

Page 4: Mecanim on Unity 4.3 実例による新機能の紹介

なぜMecanimを使うのか?

Page 5: Mecanim on Unity 4.3 実例による新機能の紹介

Animation vs Mecanim

• 昔からある • シンプル

• Unity 4から登場 • ステートマシンを作る必要がある • IKが使える

Animation(Legacy) Mecanim

Page 6: Mecanim on Unity 4.3 実例による新機能の紹介

Only for Mecanim部分的なブレンド リターゲット

「二人の漸近線」ではこの2つを積極的に利用

Page 7: Mecanim on Unity 4.3 実例による新機能の紹介

Mecanimの簡単な使い方

Page 8: Mecanim on Unity 4.3 実例による新機能の紹介

インポート設定

• コンポーネント「Animator」がアタッチされる

• インポート時にGenericまたはHumanoidを選択

Page 9: Mecanim on Unity 4.3 実例による新機能の紹介

AnimatorControllerの作成• プロジェクトウィンドウでCreate/AnimatorControllerを選択

• StateとTransitionを追加していく

Page 10: Mecanim on Unity 4.3 実例による新機能の紹介

パラメータの設定

• Transitionを選択し、遷移の発生条件を設定する

• Animatorを制御するための変数を作成

• Bool • Int • Float

Page 11: Mecanim on Unity 4.3 実例による新機能の紹介

Coding

Animator animator; !void Awake() { animator = GetComponent<Animator>(); } !void Update() { if (Input.GetKey(KeyCode.RightArrow)) { animator.SetInteger("Action", 3); } else { animator.SetInteger("Action", 0); } }

Page 12: Mecanim on Unity 4.3 実例による新機能の紹介

Mecanimの実情

Page 13: Mecanim on Unity 4.3 実例による新機能の紹介

複雑化するステートマシン

• Transition数がState数の二乗に比例して増加

• AnyStateを使いたいけれど……

Page 14: Mecanim on Unity 4.3 実例による新機能の紹介

AnyStateループ

• AnyStateで移動した先もAnyStateなので、同じTransitionが連続して発生してしまう

• ステートの遷移を監視しても完全には回避できない

• なぜならAnimatorは別スレッドだから

Page 15: Mecanim on Unity 4.3 実例による新機能の紹介

ここまでは Unity 4.2 の話

Page 16: Mecanim on Unity 4.3 実例による新機能の紹介

New in Unity 4.3• Trigger(自動でfalseになるbool値)の追加

Mecanimはようやく実用的に

• Play / CrossFadeメソッドの追加

→AnyStateループからの解放

→Transition地獄からの解放

Page 17: Mecanim on Unity 4.3 実例による新機能の紹介

AnimationEventSEとの同期

エフェクトとの同期

Page 18: Mecanim on Unity 4.3 実例による新機能の紹介

BlendShape

• リグを入れなくてもアニメーションが可能に

• モデラーが嬉しい

Page 19: Mecanim on Unity 4.3 実例による新機能の紹介

OverrideAnimatorController

レベル毎に個別のクリア演出

Page 20: Mecanim on Unity 4.3 実例による新機能の紹介

Animation Window

MechanimのモーションをUnityから編集できるようになった

カメラやライトもアニメーションできる ※FBXからインポートできるわけではない

Page 21: Mecanim on Unity 4.3 実例による新機能の紹介

まとめ

Page 22: Mecanim on Unity 4.3 実例による新機能の紹介

まとめ

• Unity 4.3でMecanimはようやく実用的に

• 人型以外でも利点はある

• そろそろLegacy Animationから乗り換えてもいいかも