概要
BlenderとUnityは座標系が異なり向きが合いません。この記事ではBlenderの作業時にその点を考慮して向きを調整した上でFBXを出力する方法をご紹介します。
![](images/blender_to_unity/blender_to_unity_01.png)
例
例えば、下図はBlenderでシーンファイルを新規に作成して Monkeyを設置したものです。ワールド空間の原点にMonkeyの中心点が位置しています。Location 0,0,0でRotation 0,0,0です。
![](images/blender_to_unity/blender_to_unity_02.png)
これをFBXに出力します。
![](images/blender_to_unity/blender_to_unity_03.png)
- Scale 1.00
- Apply Scalings: FBX Units Scale
- Forward: -Z Forward
- Up: Y Up
出力したFBXをUnityに読み込み、当該モデルを確認すると、RotationのXに-89.98と値が入っています。
![](images/blender_to_unity/blender_to_unity_04.png)
![](images/blender_to_unity/blender_to_unity_05.png)
この-89.98をゼロにするというのがこの記事の焦点です。
単純なケース
Object Modeで対象のオブジェクトをX軸の正に90度回転します。
![](images/blender_to_unity/blender_to_unity_06.png)
次にEdit Modeで対象のすべての頂点をX軸の負に90度回転します。
![](images/blender_to_unity/blender_to_unity_07.png)
その状態でFBX形式で出力してUnityに読み込みます。 下図が読み込んだ結果です。冒頭で紹介した例とは違いRotationの値がゼロになっていることがわかります。
![](images/blender_to_unity/blender_to_unity_08.png)
![](images/blender_to_unity/blender_to_unity_09.png)
オプション – Z軸
UnityのZ軸の負の方向に正面を向けたい場合はBlenderの対象オブジェクトの頂点をEdit ModeでZ軸に180度回転します。
![](images/blender_to_unity/blender_to_unity_10.png)
![](images/blender_to_unity/blender_to_unity_11.png)
下図はその状態で出力したFBXファイルを読み込んだ結果です。
もっと複雑なケース
前述のケースは1つのオブジェクトでしたが、今度は複数のオブジェクトがある場合の対処法です。下図はMonkeyと台形のオブジェクトがあるシーンです。
![](images/blender_to_unity/blender_to_unity_12.png)
各々のオブジェクトでX軸の正に90度回転すると下図のようになります。これは求める結果ではありません。
![](images/blender_to_unity/blender_to_unity_13.png)
複数を選択してから回転します。
![](images/blender_to_unity/blender_to_unity_14.png)
![](images/blender_to_unity/blender_to_unity_15.png)
位置が原点から離れているため修正します。Emptyオブジェクトを作り、それの子どもとして猿と土台部分を関連づけ、親だけを操作して位置合わせをします。
土台部分の底面をEdit Modeで選択します。
![](images/blender_to_unity/blender_to_unity_16.png)
Cursor to Selectedを選択します。
![](images/blender_to_unity/blender_to_unity_17.png)
Plain Axesを選択してEmptyオブジェクトを作成します。
![](images/blender_to_unity/blender_to_unity_18.png)
Emptyオブジェクトと猿と土台で親子関係を定義します。
![](images/blender_to_unity/blender_to_unity_19.png)
次にCursorをワールド空間の原点に移動します。ビューポートでShift + Sを押してメニューを開きCursor to World Originを選択します。
![](images/blender_to_unity/blender_to_unity_20.png)
Emptyオブジェクトをワールド空間の原点に移動させるために、ビューポートでShift + Sを押してメニューを表示してSelection to Cursorを選択します。
![](images/blender_to_unity/blender_to_unity_21.png)
![](images/blender_to_unity/blender_to_unity_22.png)
![](images/blender_to_unity/blender_to_unity_23.png)
![](images/blender_to_unity/blender_to_unity_24.png)
下図は作業が終了した時の様子です。猿はLocation X,Y,Zが0,0,0、Rotation X, Y, Zが90, 0, 0で、原点位置はワールド空間の原点に位置しています。土台も同様です。
![](images/blender_to_unity/blender_to_unity_25.png)
FBXで出力してUnityに表示した結果が下図です。猿、土台の両方ともPosition, Rotationの各値がゼロになっていることがわかります。
猿
![](images/blender_to_unity/blender_to_unity_26.png)
土台
![](images/blender_to_unity/blender_to_unity_27.png)