mecanim on unity 4.3 実例による新機能の紹介
DESCRIPTION
3Dパズルゲーム「二人の漸近線」の制作を通して、 ・Mecanimの機能をどう活用したか ・Unity 4.3でどこが便利になったか を紹介しています。TRANSCRIPT
![Page 1: Mecanim on Unity 4.3 実例による新機能の紹介](https://reader033.vdocuments.pub/reader033/viewer/2022052506/557d702ed8b42a30708b4dcf/html5/thumbnails/1.jpg)
Mecanim on Unity 4.3 !実例による新機能の紹介
2013/12/08 森本陽介
![Page 2: Mecanim on Unity 4.3 実例による新機能の紹介](https://reader033.vdocuments.pub/reader033/viewer/2022052506/557d702ed8b42a30708b4dcf/html5/thumbnails/2.jpg)
自己紹介
森本陽介
九州大学芸術工学部
卒論やばいです@YosukeM
![Page 3: Mecanim on Unity 4.3 実例による新機能の紹介](https://reader033.vdocuments.pub/reader033/viewer/2022052506/557d702ed8b42a30708b4dcf/html5/thumbnails/3.jpg)
二人の漸近線(制作中)
http://www.facebook.com/throbofencounters
http://www.facebook.com/throbofencounters
![Page 4: Mecanim on Unity 4.3 実例による新機能の紹介](https://reader033.vdocuments.pub/reader033/viewer/2022052506/557d702ed8b42a30708b4dcf/html5/thumbnails/4.jpg)
なぜMecanimを使うのか?
![Page 5: Mecanim on Unity 4.3 実例による新機能の紹介](https://reader033.vdocuments.pub/reader033/viewer/2022052506/557d702ed8b42a30708b4dcf/html5/thumbnails/5.jpg)
Animation vs Mecanim
• 昔からある • シンプル
• Unity 4から登場 • ステートマシンを作る必要がある • IKが使える
Animation(Legacy) Mecanim
![Page 6: Mecanim on Unity 4.3 実例による新機能の紹介](https://reader033.vdocuments.pub/reader033/viewer/2022052506/557d702ed8b42a30708b4dcf/html5/thumbnails/6.jpg)
Only for Mecanim部分的なブレンド リターゲット
「二人の漸近線」ではこの2つを積極的に利用
![Page 7: Mecanim on Unity 4.3 実例による新機能の紹介](https://reader033.vdocuments.pub/reader033/viewer/2022052506/557d702ed8b42a30708b4dcf/html5/thumbnails/7.jpg)
Mecanimの簡単な使い方
![Page 8: Mecanim on Unity 4.3 実例による新機能の紹介](https://reader033.vdocuments.pub/reader033/viewer/2022052506/557d702ed8b42a30708b4dcf/html5/thumbnails/8.jpg)
インポート設定
• コンポーネント「Animator」がアタッチされる
• インポート時にGenericまたはHumanoidを選択
![Page 9: Mecanim on Unity 4.3 実例による新機能の紹介](https://reader033.vdocuments.pub/reader033/viewer/2022052506/557d702ed8b42a30708b4dcf/html5/thumbnails/9.jpg)
AnimatorControllerの作成• プロジェクトウィンドウでCreate/AnimatorControllerを選択
• StateとTransitionを追加していく
![Page 10: Mecanim on Unity 4.3 実例による新機能の紹介](https://reader033.vdocuments.pub/reader033/viewer/2022052506/557d702ed8b42a30708b4dcf/html5/thumbnails/10.jpg)
パラメータの設定
• Transitionを選択し、遷移の発生条件を設定する
• Animatorを制御するための変数を作成
• Bool • Int • Float
![Page 11: Mecanim on Unity 4.3 実例による新機能の紹介](https://reader033.vdocuments.pub/reader033/viewer/2022052506/557d702ed8b42a30708b4dcf/html5/thumbnails/11.jpg)
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 実例による新機能の紹介](https://reader033.vdocuments.pub/reader033/viewer/2022052506/557d702ed8b42a30708b4dcf/html5/thumbnails/12.jpg)
Mecanimの実情
![Page 13: Mecanim on Unity 4.3 実例による新機能の紹介](https://reader033.vdocuments.pub/reader033/viewer/2022052506/557d702ed8b42a30708b4dcf/html5/thumbnails/13.jpg)
複雑化するステートマシン
• Transition数がState数の二乗に比例して増加
• AnyStateを使いたいけれど……
![Page 14: Mecanim on Unity 4.3 実例による新機能の紹介](https://reader033.vdocuments.pub/reader033/viewer/2022052506/557d702ed8b42a30708b4dcf/html5/thumbnails/14.jpg)
AnyStateループ
• AnyStateで移動した先もAnyStateなので、同じTransitionが連続して発生してしまう
• ステートの遷移を監視しても完全には回避できない
• なぜならAnimatorは別スレッドだから
![Page 15: Mecanim on Unity 4.3 実例による新機能の紹介](https://reader033.vdocuments.pub/reader033/viewer/2022052506/557d702ed8b42a30708b4dcf/html5/thumbnails/15.jpg)
ここまでは Unity 4.2 の話
![Page 16: Mecanim on Unity 4.3 実例による新機能の紹介](https://reader033.vdocuments.pub/reader033/viewer/2022052506/557d702ed8b42a30708b4dcf/html5/thumbnails/16.jpg)
New in Unity 4.3• Trigger(自動でfalseになるbool値)の追加
Mecanimはようやく実用的に
• Play / CrossFadeメソッドの追加
→AnyStateループからの解放
→Transition地獄からの解放
![Page 17: Mecanim on Unity 4.3 実例による新機能の紹介](https://reader033.vdocuments.pub/reader033/viewer/2022052506/557d702ed8b42a30708b4dcf/html5/thumbnails/17.jpg)
AnimationEventSEとの同期
エフェクトとの同期
![Page 18: Mecanim on Unity 4.3 実例による新機能の紹介](https://reader033.vdocuments.pub/reader033/viewer/2022052506/557d702ed8b42a30708b4dcf/html5/thumbnails/18.jpg)
BlendShape
• リグを入れなくてもアニメーションが可能に
• モデラーが嬉しい
![Page 19: Mecanim on Unity 4.3 実例による新機能の紹介](https://reader033.vdocuments.pub/reader033/viewer/2022052506/557d702ed8b42a30708b4dcf/html5/thumbnails/19.jpg)
OverrideAnimatorController
レベル毎に個別のクリア演出
![Page 20: Mecanim on Unity 4.3 実例による新機能の紹介](https://reader033.vdocuments.pub/reader033/viewer/2022052506/557d702ed8b42a30708b4dcf/html5/thumbnails/20.jpg)
Animation Window
MechanimのモーションをUnityから編集できるようになった
カメラやライトもアニメーションできる ※FBXからインポートできるわけではない
![Page 21: Mecanim on Unity 4.3 実例による新機能の紹介](https://reader033.vdocuments.pub/reader033/viewer/2022052506/557d702ed8b42a30708b4dcf/html5/thumbnails/21.jpg)
まとめ
![Page 22: Mecanim on Unity 4.3 実例による新機能の紹介](https://reader033.vdocuments.pub/reader033/viewer/2022052506/557d702ed8b42a30708b4dcf/html5/thumbnails/22.jpg)
まとめ
• Unity 4.3でMecanimはようやく実用的に
• 人型以外でも利点はある
• そろそろLegacy Animationから乗り換えてもいいかも