バージョン
menu_open
警告:あなたのメジャーリリース ( 2023.1.4.8496 ) に該当する最新ドキュメンテーションが表示されています。特定バージョンのドキュメンテーションにアクセスするには、Audiokinetic Launcherでオフラインドキュメンテーションをダウンロードし、Wwise AuthoringのOffline Documentationオプションにチェックを入れてください。
Wwise Unreal Integration Documentation
Spatial Audioのブループリントコンポーネント

これまで、ビルド済みのアクターを使ったり、個別のアクターインスタンスにコンポーネントを追加したりして、全てのものをレベルに直接つくり込んできました。スペーシャルオーディオの各種コンポーネントを使ってブループリントアクターをつくり、レベルのいたるところで複製することも可能です。このセクションでは、 Wwiseプロジェクトの準備 セクションのストラクチャの複製を、ブループリントクラスを使ってビルドし、ワールドのどこにでも簡単に追加したりスポーンしたりできるようにします。

注記: このチュートリアルを始める前に、 Spatial Audioチュートリアルの事前準備 を完了させておいてください。

ブループリントクラスを設定する

AkLateReverbComponentAkRoomComponent は、あるゲームオブジェクトのポジションが親の PrimitiveComponent の中にあるのかどうかを確認するときに、コンテインメントテストを行います。確認にはSimpleコリジョンを使います。そこで、Simpleコリジョンのある親 PrimitiveComponent を使ってください。例えば、Boxコリジョン、Sphereコリジョン、Capsuleコリジョンなどのコンポーネントが使えます。 PrimitiveComponent にSimpleコリジョンがなければ、Component boundsをコンテインメントテストに使うだけですが、正確性は劣るかもしれません。

Unrealで、メッシュアセットにSimpleコリジョンを追加することも可能です( Setting Up Collision With Static Meshes を参照)。ただし、戸口や開口部などのある複雑なメッシュの場合は、メッシュのコリジョン設定で'Use complex collision as simple'とする必要があるかもしれません( Simple Vs Complex Collision を参照)。例えば、キャラクターがドアを通過してルームに入れても、そのルームの壁には衝突してしまうようにするには、この設定が必要かもしれません。この設定を使うと、Simpleコリジョンは無視され、メッシュの三角メッシュ全体が使われるので、 AkLateReverbComponentAkRoomComponent のコンテインメントテストは、失敗します。 AkLateReverbComponentAkRoomComponent が使うSimpleコリジョンテストは、三角メッシュに対応していません。そこでブループリントクラスの推奨設定として、 AkLateReverbComponent コンポーネントや、 AkRoomComponent を使うときは、Simpleコリジョンコンポーネントを親にします。Simpleコリジョンコンポーネントとは、Box、Sphere、Capsuleなどです。具体的なメッシュを部屋や建物に設定した場合は、Simpleコリジョンコンポーネントをこのメッシュの子コンポーネントとして追加できます。

注記: It is possible to combine complex collision with simple collision by using two versions of the mesh. See Combining Simple and Complex Collision for an explanation on how this can be achieved.
注記: We will use assets from the Unreal Demo Game available from the Wwise Launcher. To use these assets in your project, download the Unreal Demo Game and locate the wanted assets in the explorer under $<YourWwiseProjectsFolder>/WwiseDemoGame/Content. Then copy and paste the desired assets to the Content folder of your working project.
  1. コンテンツブラウザを右クリックし、 Blueprint Class を選択します。
  2. ベースクラスに Actor を選択し、この新しいクラスの名前を 'SpatialAudioBP' とします。
  3. SpatialAudioBP をダブルクリックしてこのクラスを開き、Viewportタブをクリックします。
  4. ルートコンポーネントが選択されていることを確認し、 Add Component > Static Mesh をクリックします。
  5. 新しいスタティックメッシュコンポーネントをクリックし、このメッシュをDetailsパネルで選択します。

    • この例では、 Wwiseプロジェクトの準備 セクションで使ったSpatialAudioDemoMeshを選択しました。
    • SpatialAudioDemoMeshを使う場合は、必ずMaterialsセクションで SpatialAudioDemoMeshMaterial を選択します。
    スタティックメッシュコンポーネントのMeshとMaterialsを設定する
    注記: ポータルに対するルームの自動アサインは、凸型メッシュでしか機能しません。凹型メッシュ(L字型のルームなど)の場合、ポータルとルームの正確なIntersectionができません。
  6. メッシュの中のルームや戸口に、それぞれBoxコリジョンコンポーネントを追加します。

    • このチュートリアルに出てくるBoxコリジョンコンポーネントには、BoxRoomLarge、BoxRoomSmall、BoxPortalInner、そしてBoxPortalOuterという名前を付けました。
    あなたのメッシュのルームやポータルに、Boxコリジョンコンポーネントを追加する

Boxコリジョンコンポーネントを移動する

この時点では、全てのBoxコリジョンコンポーネントが同じ場所に重ねて置いてあります。これから、ポジションを変え、拡大縮小し、回転することで、ルームやドアに揃えていきます。一番簡単な方法は、正投影のビューを使うことです。(以下の手順はSpatialAudioDemoMeshのためですが、ほかのメッシュでも同じような手順が使えます。)

注記: チュートリアルでルームやポータルと、メッシュの位置を揃えるときに、ぴったりと揃わなかったり中心が合わなかったりしても、構いません。だいたい同じ場所をカバーするようにします。本物の環境を設計する際は、DetailsパネルのTransformセクションで、正確な数値を入力できます。
  1. Viewportタブで Perspective をクリックし、ビューを Top に変えます。

    • 上からシーンを見下ろしたビューとなり、ワイヤーフレームのレンダリングが表示されます。
    正投影のTopビュー
  2. BoxRoomLarge を選択し、Y軸に沿って下に動かし、メッシュの大きいルームの中央にもってきます。
  3. BoxRoomLarge の縮尺をXY軸に沿って調整し、大きさが大きいルームの寸法に合うようにします。(スケール機能に切り替えるには、Rを押すか、Viewportタブのスケールウィジェットを選択します。)

    XY軸に沿ってLarge Roomのポジションと縮尺を調整する
  4. BoxRoomSmall を選択し、XY軸に沿って縮尺を調整し、大きさが、小さいルームの寸法に合うようにします。

    XY軸に沿ってRoomのポジションと縮尺を調整する
  5. BoxPortalInner を選択し、ワイヤーフレームにズームインし、メッシュに内側の戸口の範囲が見えるようにします。

    ワイヤーフレームメッシュで、戸口の両端を確認する
  6. BoxPortalInner を戸口の中央まで動かし、X軸に沿って縮尺を調整して戸口の両端をカバーするようにします。

    Inner Portal Boxが戸口をカバーするように、ポジションと縮尺を調整する
  7. BoxPortalOuter を選択し、ローカルのY方向が戸口の外を指すように回転させます。

    注記: 理由は、ポータルに対する「フロント」ルームと「バック」ルームが、ポータルのY方向と交差する一番近いルームを検知することで自動的に決まるからです。BoxPortalOuterの例では、「バック」側(ローカル座標空間において)が、メッシュの小ルームに接続し、「フロント」側は、接続するルームがありません。
  8. BoxPortalOuter をZ軸を中心に90度、回転させます。これは、DetailsパネルのTransformセクションにある Rotation の、Z軸のテキストボックスに'90'と入力すればできます。

    ローカルY軸がドアの外を指すように、Outer Portal Boxを回転させる
  9. BoxPortalOuter が外側のドアの上にくるように動かし、戸口の両端をカバーするように縮尺を調整します。
  10. Topビューで、下図のように全てのルームやポータルが、メッシュと揃っていることを確認します:

    Topビューで、正しく揃っているルームやポータル
  11. 次に、BoxコリジョンコンポーネントをZ軸に沿って動かし、ポジションと縮尺を調整します。Viewportタブの Top をクリックし、ビューを Back に変更します。
  12. BoxRoomLargeBoxRoomSmall を選択し、どちらもルームの大きさに合うように、Z軸方向にスケールを調整します。

    ルームのボックスの縮尺を、Z軸に沿って調整する
  13. BoxPortalOuterBoxPortalInner を選択し、それぞれの戸口の中まで下に動かし、Z軸方向に縮尺を調整し、それぞれのドアの大きさに合わせます。

    Z軸に沿ってPortal Boxのポジションと縮尺を調整する

ルームとポータルを設定する

次に、AkRoomコンポーネントをルームに追加し、AkPortalコンポーネントをポータルに追加します。

  1. Boxコリジョンコンポーネントを1つ1つ選択して Add Component を選択します。
  2. それぞれのBoxコリジョンコンポーネントに対し、適宜、ルームコンポーネントまたはポータルコンポーネントを作成し、親と似た名前を付けます。以下のような結果になるはずです:

    AkRoom ComponentをRoom Boxに、AkPortal ComponentをPortal Boxに追加する

    注記: 各コンポーネントを正しい親に追加するように、注意してください。例えば、大きいルームにAkRoomLargeを追加するときは、必ず BoxRoomLarge が選択されていることを確認してから、 Add Component をクリックしてください。

    AkRoomComponentやAkPortalComponentは、どのようなPrimitiveコンポーネントにも追加できる汎用コンポーネントです。詳細は、 AkRoomComponent や、 AkPortalComponent を参照してください。

  3. ポータルが正しく配置されていることを確認するために、Integration Settingsの Visualize Rooms and Portals オプションを選択します。

    Integration SettingsのVisualize Rooms and Portalsオプション
  4. 接続しているルームとポータルの間に、線が表示されます。ポータルの配置が無効であれば、赤色で表示されます。

    Viewportに表示されたポータルとルームのつながり
    注記: ポータルに接続するルームがなかったり、同じルームがポータルの内外両側に接続していたりすると、このポータルの設定は無効です。詳細は AkPortalComponent を参照してください。
  5. Integration Settingsで Visualize Rooms and Portals オプションの選択を外します。

ジオメトリとレイトリバーブを追加する

最後に、ブループリントクラスにAkGeometryとAkLateReverbの2つのコンポーネントを追加します。

  1. スタティックメッシュコンポーネントに、AkGeometryコンポーネントを追加します。
  2. BoxコリジョンコンポーネントのBoxRoomLargeに、AkLateReverbコンポーネントを追加します。

    ブループリントクラスに、AkGeometryとAkLateReverbを追加する
  3. AkLateReverb コンポーネントをクリックします。
  4. Detailsパネルで、Auxバスを LargeRoom に設定します。

設定内容を確認する

これで、ブループリントクラスを使う準備が整いました。このクラスのインスタンスを、ワールドにドラッグして入れることができます。

  1. SpatialAudioBP のインスタンスをコンテンツブラウザからスペーシャルオーディオのデモマップにドラッグします。
  2. すでにある建物の横に置きます。

    ワールドに追加された、ブループリントクラスのインスタンス
  3. Wwiseにリモート接続してEditorでプレイします。
  4. マウスをクリックし、屋外サウンドを再生します。
  5. WwiseのGame Object Profilerレイアウトで、新しいブループリントクラスのジオメトリが正しく登録されていて、このジオメトリでレイ(ray)が正しく反射されていることを確認します。
  6. レイが、新しいブループリントのストラクチャの中で、ポータルを通り抜けていることを確認します。

    Spatial Audioのパスと、新しいブループリントクラスのインスタンスが、正しく作用し合っているる様子
  7. レイトリバーブコンポーネントをテストするには、このSpatialAudioBPインスタンスの中の大きいルームに、サウンドを追加して配置する必要があります。ワールドにすでにある Play_Outside というAkAmbientSoundアクターを右クリックし、Duplicate(複製)します。

    既存のPlay_Outsideサウンドを複製する
  8. 複製の名前を 'Play_LargeRoom_BP' に変更します。(別の方法として、 Play_LargeRoom_BP をドラッグして Button_Outside の上にもっていけば、World Outliner階層にあるButton_OutsideのPlay_LargeRoom_BPを分離できます。)
  9. Play_LargeRoom_BP を、このSpatilAudioBPインスタンスの大きいルームにもっていきます。

    サウンドを大きいルーム内に配置する
  10. Level Blueprintを開き、Bキーを押したときにPlay_LargeRoom_BPサウンドを再生するための、ロジックを追加します( Wwiseプロジェクトの準備 のステップ3を参照)。

    新しいサウンドをBキーで再生させるための、Level Blueprintのロジック
  11. Level Blueprintをコンパイルして保存します。
  12. Editorで再生します。
  13. Bを押して新しいサウンドを再生します。
  14. SpatialAudioBPの建物の大きいルームに、歩いて入ります。
    • リバーブが適用されるのが聞こえるはずです。

Combining Simple and Complex Collision

注記: This section is based on the 'SpatialAudioTutorialMap' and the assets found in the ComplexRoomDemo directory in the WwiseDemoGame project, which is available from the Audiokinetic Launcher. The pre-made mesh assets and a custom Blueprint class are used to combine simple collision and complex collision.

This section shows how simple collision and complex collision can be combined for the same mesh, such that Spatial Audio containment tests are performed using the simple collision, and Unreal queries make use of the complex collision.

For complex meshes, such as those with doorways and openings, it is sometimes necessary to 'use complex collision as simple' in the collision settings for the mesh (refer to Simple Vs Complex Collision). 例えば、キャラクターがドアを通過してルームに入れても、そのルームの壁には衝突してしまうようにするには、この設定が必要かもしれません。この設定を使うと、Simpleコリジョンは無視され、メッシュの三角メッシュ全体が使われるので、 AkLateReverbComponentAkRoomComponent のコンテインメントテストは、失敗します。 AkLateReverbComponentAkRoomComponent が使うSimpleコリジョンテストは、三角メッシュに対応していません。

One solution to this is to create two duplicates of the same mesh asset, using simple collision for one, and complex collision for the other. In the SpatialAudioTutorialMap, there is a complex room structure for which this technique has been used.

To begin, test out the complex room structure by playing in editor and walking around the building:

  • Open the SpatialAudioTutorialMap in Unreal.
  • Activate the 'Play in Editor' option.
  • Press 'C' to trigger the sound in the non-box-shaped building.
    The Non-Box-Shaped Room in the SpatialAudioTutorialMap
    • You can walk around the outside of the building and the sound will be occluded.

Follow along with the remainder of this tutorial to see how the building structure is set up to handle both simple collision, for Wwise Spatial Audio containment tests, and complex collision, for Unreal physics containment tests.

  • In the context browser, browse to WwiseAssets/SpatialAudioDemo/ComplexRoomDemo.

    The ComplexRoomDemo Assets in the SpatialAudioTutorialMap

This folder contains two Static Mesh assets - 'Building_Complex' and 'Building_Simple'.

  • Open each of these assets and scroll to the collision settings in the Details Panel.

You will notice that they have different values assigned to the Collision Complexity property.

The Building_Complex mesh asset
The Building_Simple mesh asset

Building_Complex has Collision Complexity set to 'Use Complex Collision As Simple' which means Unreal will not generate any simplified geometry for this mesh, and will instead use the entire trimesh. This is what allows the character to walk through the doorway opening. Building_Simple has Collision Complexity set to 'Use Simple Collision As Complex' which means Unreal will generate simplified geometry and ignore the trimesh. This is what allows Spatial Audio to perform containment tests for room containment.

注記: It is possible to set Collision Complexity to 'Simple And Complex'. However, this causes Unreal to use the simplified geometry for collision queries, which means the character cannot enter through the doorway opening. Instead, two identical meshes can be used - one with complex geometry and one with simple geometry.

The next step is to combine both meshes inside a custom Blueprint class.

  • Open the BuildingBP Blueprint.

This Blueprint uses two Static Mesh Components that are positioned right on top of one another.

Static Mesh Components in the BuildingBP Blueprint
For the StaticMesh_Complex component, the Building_Complex mesh is used
For the StaticMesh_Simple component, the Building_Simple mesh is used
StaticMesh_Simple Rendering Settings

For the StaticMesh_Simple component, 'Visible' is disabled and 'Hidden in Game' is enabled in the Rendering section. This is because this mesh is only used for its simplified geometry, so that containment tests can be made for Spatial Audio.

StaticMesh_Simple Collision Presets Settings

Also for the StaticMesh_Simple component, the Collision Presets property is set to 'Trigger'. The simplified geometry creates a barrier at the doorway opening. Using the 'Trigger' collision preset ensures the character and other game objects can freely move through the simplified geometry.

The StaticMesh_Simple Component has an AkRoom component and an AkLateReverb Component attached. This way, the simple collision of the Building_Simple mesh is used for room containment tests.

To allow for sounds to reflect and diffract on the BuildingBP's mesh, an AkGeometry Component needs to be added to one of the Static Mesh Components. In this solution, since we are also using Reverb Parameter Estimation, it is best to add it to the StaticMesh_Simple component. The AkLateReverb Component uses the Acoustic Textures of its sibling AkGeometry Component to calculate HF Damping. Setting the AkGeometry Component to Static Mesh sends the full complex geometry to Wwise Spatial Audio instead of its simple collision mesh.

Finally, a Box Collision Component with an AkPortal Component attached is used to add an acoustic portal to the doorway.

Portal in the BuildingBP Blueprint

A Point Light is also added to make the interior of the building visible.

注記: When sending geometry to Wwise, there is a limitation that each edge can have no more than two triangles connected. This should be taken into account when designing meshes to be used with Spatial Audio.
注記: When using the Game Object Profiler in Wwise, Room Extents will always be visualized as green cuboids, regardless of the geometry assigned to the room.
注記: Adding simple collision to meshes in Unreal will only work correctly when the mesh is convex. For more complex mesh structures, it is best to try to approximate the mesh using simple collision geometry. Simple collision primitives can be added to the mesh from the Collision menu in the Static Mesh editor.
Adding Collision Primitives to a Mesh Asset
Refer to Setting Up Collision With Static Meshes for further information.

このページはお役に立ちましたか?

サポートは必要ですか?

ご質問や問題、ご不明点はございますか?お気軽にお問い合わせください。

サポートページをご確認ください

あなたのプロジェクトについて教えてください。ご不明な点はありませんか。

プロジェクトを登録していただくことで、ご利用開始のサポートをいたします。

Wwiseからはじめよう