無料でゲームも作れる Unity には、カメラを操作するために便利な Cinemachine モジュールがあります。
全2話で Unity の Cinemachine の Dolly Cart の機能を使って、3D のゲームオブジェクトを作成したパス(経路)に沿ってなめらかに移動させる手順を紹介します。

今回、第1話では、パスを作成して編集する手順と、CinemachinePath と CinemachineSmoothPath の二つのパスのコンポーネントの違いについても説明します。
前回の記事
前回は、無料でゲームも作れる Unity で、映画のようなカメラワークを実現できる Cinemachine の導入と、その中にあるパスに沿って移動させる機能 Dolly Cart について紹介しました。
CinemachinePath と CinemachineSmoothPath の違い
ゲームオブジェクトの移動経路、ドリーパスを描くために、Cinemachine には Path と SmoothPath の 2 つのパスがあります。

その二つのパスのコンポーネントの違いは、ガタつきの有無と、デザインの自由度です。
CinemachineSmoothPath は、 WayPoint のつなぎ目でガタつかない長所があります。
パスは全てのウェイポイントを通過します。Cinemachine Smooth Path では、Cinemachine Path と異なり、1 つ目と 2 つ目の順序の連続性が確保されます。つまり、パスに沿って動かされるオブジェクトの、位置だけでなく角速度も、滑らかで連続的になるということです。
Cinemachine Smooth Path | Cinemachine | 2.6.0
一方、 CinemachinePath は、タンジェントという項目を設定でき、より細かなデザインのパスを作成できる長所があります。
各ウェイポイントが位置、タンジェント、ロールを持っています。Path を使用するとウェイポイント間のトラックの位置をより細かく制御できます。
ドリーパスの使用 | Cinemachine | 2.6.0
移動経路のパスを作成
今回は、凝ったデザインをしないことと、滑らかな曲線で移動してほしいので、 CinemachineSmoothPath コンポーネントでドリーパスを作成します。
Hierarchy ウィンドウで空のゲームオブジェクトを作成して、適当な名前に変更します。
そのゲームオブジェクトを選択した状態で、メインメニュー Component > Cinemachine > CinemacineSmoothPath を選択して、コンポーネントを追加します。
※空のゲームオブジェクトを作るには、Hierarchy ウィンドウの余白を右クリックして表示されたメニューから Create Empty を選びます。

始点と終点の 2 つの WayPoint を持つ直線のドリーパスがシーンに配置されました。
丸の中の数字は CinemachineSmoothPath コンポーネントの WayPoints の要素番号に対応しています。

Inspector ウィンドウの CinemachineSmoothPath コンポーネントの Waypoints リストの右下の + ボタンを押すと、中継点、 WayPoint を増やすことができます。

Waypoints リストの行をクリックすると、その Waypoint が選択されます。
Scene ウィンドウで選択された Waypoint の位置を移動させると、ドリーパスも変形します。
Waypoint を増やすことで、さらに複雑なドリーパスを作成できます。

今回はここまで
今回、第1話では、無料でゲームも作れる Unity の、カメラの便利な機能をまとめた Cinemacine モジュールの Dolly Cart の機能を使って、パスを作成して編集する手順と、CinemachinePath と CinemachineSmoothPath の二つのパスのコンポーネントの違いについても説明しました。
参照サイト Thank You!
- Unity のリアルタイム開発プラットフォーム | 2D/3D、VR/AR エンジン
- Cinemachine
- Cinemachine について | Cinemachine | 2.6.0
- About Cinemachine | Cinemachine | 2.9.7
- ドリーパスの使用 | Cinemachine | 2.6.0
- Cinemachine Path | Cinemachine | 2.6.0
- Cinemachine Smooth Path | Cinemachine | 2.6.0
- Cinemachine Dolly Cart | Cinemachine | 2.6.0
記事一覧 → Compota-Soft-Press
コメント