UDN
Search public documentation:

DevelopmentKitGemsCreatingAModularPawnJP
English Translation
中国翻译
한국어

Interested in the Unreal Engine?
Visit the Unreal Technology site.

Looking for jobs and company info?
Check out the Epic games site.

Questions about support via UDN?
Contact the UDN Staff

Unreal Development Kit ホーム > Unreal Development Kit Gems > モジュラーポーンの作成方法

モジュラーポーンの作成方法


2011年3月に UDK について最終テスト実施済み
PC および iOS 対応

概要


最近のゲームでは、バーチャルアバターの外見をプレイヤーがカスタマイズできるようになっています。ソケットまたはボーンによるアタッチメントは、アニメートしないビジュアルや個別にアニメートするビジュアルの場合には非常に良く機能しますが、バーチャルアバターを単一の実体として動かす場合は、それほど良く機能しません。たとえば、プレイヤーがシャツとパンツを選択してアバターを作成できるようにする場合のことを考えてみます。ヒューマノイドは、これらのパーツが組み合わされて構成されるため、アニメーションが正しくシンクロナイズしていない場合は現実味が非常に乏しくなります。

次の例では、Lauryn が異なるショルダーパッド、異なるブーツ、異なる腕をともなっています。シャドウとアニメーションはほとんど手間がかからず自動的に機能します。

ModularPawnTitle.jpg

メソッド


このエフェクトを得るには 2 つの方法があります。
  • アクタ単位の複数の骨格メッシュコンポーネント - この方法は、実行時に骨格メッシュを変更することが可能であるため、最も柔軟です。ただし、パフォーマンスに影響します。骨格メッシュアクタがそれぞれ余分な描画コールとなるためです。
  • メッシュの合成 (ライセンシー限定) - この方法は、メッシュを合成することによって、複数のメッシュから単一のメッシュを生成します。本資料ではこの方法について説明しません。

関連テーマ

モジュラーポーンをスクリプト処理する


下にあるのは、複数の骨格メッシュコンポーネントを定義するモジュラーポーンクラスです。各骨格メッシュコンポーネントは、他の部分のためにスポーンさせることが可能なポーンの部分を表します。1 つの骨格メッシュコンポーネントだけが親骨格メッシュコンポーネントになります。この例では、頭の骨格メッシュコンポーネントが親です。

親骨格メッシュコンポーネントは、骨格アニメーションのデータを計算します。このデータは、すべての子骨格メッシュコンポーネントによって使用されます。すべての子骨格メッシュコンポーネントは、親から平行移動、回転、スケールのデータも受け取ります。

最善の結果を得るには、すべての骨格メッシュが同一の骨格を使用するとともに、同一のアニメーションのために設計されるようにします。頂点はすべて骨格に直接マップされる必要があります。これは、エクスポートする前に各骨格メッシュを再センター化する必要がないためです。

最後に、すべての子骨格メッシュコンポーネントの親シャドウは、同一の親骨格メッシュコンポーネントに設定されます。これによって、動的シャドウをレンダリングする際に、パフォーマンスを向上させるとともに、シャドウの重複問題を防ぐことができます。

ModularPawn.uc
class ModularPawn extends UTPawn
  Placeable;

// Skeletal mesh which represents the head. Parent skeletal mesh component.
var(ModularPawn) const SkeletalMeshComponent HeadSkeletalMesh;
// Skeletal mesh which represents the torso. Child to the head skeletal mesh component.
var(ModularPawn) const SkeletalMeshComponent TorsoSkeletalMesh;
// Skeletal mesh which represents the arms. Child to the head skeletal mesh component.
var(ModularPawn) const SkeletalMeshComponent ArmsSkeletalMesh;
// Skeletal mesh which represents the thighs. Child to the head skeletal mesh component.
var(ModularPawn) const SkeletalMeshComponent ThighsSkeletalMesh;
// Skeletal mesh which represents the boots. Child to the head skeletal mesh component.
var(ModularPawn) const SkeletalMeshComponent BootsSkeletalMesh;
// Skeletal mesh which represents the left shoulder pad. Child to the head skeletal mesh component.
var(ModularPawn) const SkeletalMeshComponent LeftShoulderPadSkeletalMesh;
// Skeletal mesh which represents the right shoulder pad. Child to the head skeletal mesh component.
var(ModularPawn) const SkeletalMeshComponent RightShoulderPadSkeletalMesh;

defaultproperties
{
  // Remove UTPawn's defined skeletal mesh
  Components.Remove(WPawnSkeletalMeshComponent)

  // Create the animation sequence
  Begin Object class=AnimNodeSequence Name=AnimNodeSequence
  End Object

  // Create the head skeletal mesh component
  Begin Object Class=SkeletalMeshComponent Name=HeadSkeletalMeshComponent
    bCacheAnimSequenceNodes=false
    AlwaysLoadOnClient=true
    AlwaysLoadOnServer=true
    bOwnerNoSee=true
    CastShadow=true
    BlockRigidBody=true
    bUpdateSkelWhenNotRendered=false
    bIgnoreControllersWhenNotRendered=true
    bUpdateKinematicBonesFromAnimation=true
    bCastDynamicShadow=true
    RBChannel=RBCC_Untitled3
    RBCollideWithChannels=(Untitled3=true)
    LightEnvironment=MyLightEnvironment
    bOverrideAttachmentOwnerVisibility=true
    bAcceptsDynamicDecals=false
    AnimTreeTemplate=AnimTree'CH_AnimHuman_Tree.AT_CH_Human'
    bHasPhysicsAssetInstance=true
    TickGroup=TG_PreAsyncWork
    MinDistFactorForKinematicUpdate=0.2
    bChartDistanceFactor=true
    RBDominanceGroup=20
    MotionBlurScale=0.0
    bUseOnePassLightingOnTranslucency=true
    bPerBoneMotionBlur=true
    // Set the animation node sequence so we can test the animation
    Animations=AnimNodeSequence
  End Object
  HeadSkeletalMesh=HeadSkeletalMeshComponent
  Components.Add(HeadSkeletalMeshComponent)

  // Create the torso skeletal mesh component
  Begin Object Class=SkeletalMeshComponent Name=TorsoSkeletalMeshComponent
    bCacheAnimSequenceNodes=false
    AlwaysLoadOnClient=true
    AlwaysLoadOnServer=true
    bOwnerNoSee=true
    CastShadow=true
    BlockRigidBody=true
    bUpdateSkelWhenNotRendered=false
    bIgnoreControllersWhenNotRendered=true
    bUpdateKinematicBonesFromAnimation=true
    bCastDynamicShadow=true
    RBChannel=RBCC_Untitled3
    RBCollideWithChannels=(Untitled3=true)
    LightEnvironment=MyLightEnvironment
    bOverrideAttachmentOwnerVisibility=true
    bAcceptsDynamicDecals=false
    bHasPhysicsAssetInstance=true
    TickGroup=TG_PreAsyncWork
    MinDistFactorForKinematicUpdate=0.2
    bChartDistanceFactor=true
    RBDominanceGroup=20
    MotionBlurScale=0.0
    bUseOnePassLightingOnTranslucency=true
    bPerBoneMotionBlur=true
    // Assign the parent animation component to the head skeletal mesh component. This ensures that
    // the pawn animates as if it was one skeletal mesh component.
    ParentAnimComponent=HeadSkeletalMeshComponent
    // Assign the shadow parent component to the head skeletal mesh component. This is used to speed up
    // the rendering of the shadow for this pawn and to prevent shadow overlaps from occur.
    ShadowParent=HeadSkeletalMeshComponent
  End Object
  TorsoSkeletalMesh=TorsoSkeletalMeshComponent
  Components.Add(TorsoSkeletalMeshComponent)

  // Create the arms skeletal mesh component
  Begin Object Class=SkeletalMeshComponent Name=ArmsSkeletalMeshComponent
    bCacheAnimSequenceNodes=false
    AlwaysLoadOnClient=true
    AlwaysLoadOnServer=true
    bOwnerNoSee=true
    CastShadow=true
    BlockRigidBody=true
    bUpdateSkelWhenNotRendered=false
    bIgnoreControllersWhenNotRendered=true
    bUpdateKinematicBonesFromAnimation=true
    bCastDynamicShadow=true
    RBChannel=RBCC_Untitled3
    RBCollideWithChannels=(Untitled3=true)
    LightEnvironment=MyLightEnvironment
    bOverrideAttachmentOwnerVisibility=true
    bAcceptsDynamicDecals=false
    bHasPhysicsAssetInstance=true
    TickGroup=TG_PreAsyncWork
    MinDistFactorForKinematicUpdate=0.2
    bChartDistanceFactor=true
    RBDominanceGroup=20
    MotionBlurScale=0.0
    bUseOnePassLightingOnTranslucency=true
    bPerBoneMotionBlur=true
    // Assign the parent animation component to the head skeletal mesh component. This ensures that
    // the pawn animates as if it was one skeletal mesh component.
    ParentAnimComponent=HeadSkeletalMeshComponent
    // Assign the shadow parent component to the head skeletal mesh component. This is used to speed up
    // the rendering of the shadow for this pawn and to prevent shadow overlaps from occur.
    ShadowParent=HeadSkeletalMeshComponent
  End Object
  ArmsSkeletalMesh=ArmsSkeletalMeshComponent
  Components.Add(ArmsSkeletalMeshComponent)

  // Create the thighs skeletal mesh component
  Begin Object Class=SkeletalMeshComponent Name=ThighsSkeletalMeshComponent
    bCacheAnimSequenceNodes=false
    AlwaysLoadOnClient=true
    AlwaysLoadOnServer=true
    bOwnerNoSee=true
    CastShadow=true
    BlockRigidBody=true
    bUpdateSkelWhenNotRendered=false
    bIgnoreControllersWhenNotRendered=true
    bUpdateKinematicBonesFromAnimation=true
    bCastDynamicShadow=true
    RBChannel=RBCC_Untitled3
    RBCollideWithChannels=(Untitled3=true)
    LightEnvironment=MyLightEnvironment
    bOverrideAttachmentOwnerVisibility=true
    bAcceptsDynamicDecals=false
    bHasPhysicsAssetInstance=true
    TickGroup=TG_PreAsyncWork
    MinDistFactorForKinematicUpdate=0.2
    bChartDistanceFactor=true
    RBDominanceGroup=20
    MotionBlurScale=0.0
    bUseOnePassLightingOnTranslucency=true
    bPerBoneMotionBlur=true
    // Assign the parent animation component to the head skeletal mesh component. This ensures that
    // the pawn animates as if it was one skeletal mesh component.
    ParentAnimComponent=HeadSkeletalMeshComponent
    // Assign the shadow parent component to the head skeletal mesh component. This is used to speed up
    // the rendering of the shadow for this pawn and to prevent shadow overlaps from occur.
    ShadowParent=HeadSkeletalMeshComponent
  End Object
  ThighsSkeletalMesh=ThighsSkeletalMeshComponent
  Components.Add(ThighsSkeletalMeshComponent)

  // Create the boots skeletal mesh component
  Begin Object Class=SkeletalMeshComponent Name=BootsSkeletalMeshComponent
    bCacheAnimSequenceNodes=false
    AlwaysLoadOnClient=true
    AlwaysLoadOnServer=true
    bOwnerNoSee=true
    CastShadow=true
    BlockRigidBody=true
    bUpdateSkelWhenNotRendered=false
    bIgnoreControllersWhenNotRendered=true
    bUpdateKinematicBonesFromAnimation=true
    bCastDynamicShadow=true
    RBChannel=RBCC_Untitled3
    RBCollideWithChannels=(Untitled3=true)
    LightEnvironment=MyLightEnvironment
    bOverrideAttachmentOwnerVisibility=true
    bAcceptsDynamicDecals=false
    bHasPhysicsAssetInstance=true
    TickGroup=TG_PreAsyncWork
    MinDistFactorForKinematicUpdate=0.2
    bChartDistanceFactor=true
    RBDominanceGroup=20
    MotionBlurScale=0.0
    bUseOnePassLightingOnTranslucency=true
    bPerBoneMotionBlur=true
    // Assign the parent animation component to the head skeletal mesh component. This ensures that
    // the pawn animates as if it was one skeletal mesh component.
    ParentAnimComponent=HeadSkeletalMeshComponent
    // Assign the shadow parent component to the head skeletal mesh component. This is used to speed up
    // the rendering of the shadow for this pawn and to prevent shadow overlaps from occur.
    ShadowParent=HeadSkeletalMeshComponent
  End Object
  BootsSkeletalMesh=BootsSkeletalMeshComponent
  Components.Add(BootsSkeletalMeshComponent)

  // Create the left shoulder pad skeletal mesh component
  Begin Object Class=SkeletalMeshComponent Name=LeftShouldPadSkeletalMeshComponent
    bCacheAnimSequenceNodes=false
    AlwaysLoadOnClient=true
    AlwaysLoadOnServer=true
    bOwnerNoSee=true
    CastShadow=true
    BlockRigidBody=true
    bUpdateSkelWhenNotRendered=false
    bIgnoreControllersWhenNotRendered=true
    bUpdateKinematicBonesFromAnimation=true
    bCastDynamicShadow=true
    RBChannel=RBCC_Untitled3
    RBCollideWithChannels=(Untitled3=true)
    LightEnvironment=MyLightEnvironment
    bOverrideAttachmentOwnerVisibility=true
    bAcceptsDynamicDecals=false
    bHasPhysicsAssetInstance=true
    TickGroup=TG_PreAsyncWork
    MinDistFactorForKinematicUpdate=0.2
    bChartDistanceFactor=true
    RBDominanceGroup=20
    MotionBlurScale=0.0
    bUseOnePassLightingOnTranslucency=true
    bPerBoneMotionBlur=true
    // Assign the parent animation component to the head skeletal mesh component. This ensures that
    // the pawn animates as if it was one skeletal mesh component.
    ParentAnimComponent=HeadSkeletalMeshComponent
    // Assign the shadow parent component to the head skeletal mesh component. This is used to speed up
    // the rendering of the shadow for this pawn and to prevent shadow overlaps from occur.
    ShadowParent=HeadSkeletalMeshComponent
  End Object
  LeftShoulderPadSkeletalMesh=LeftShouldPadSkeletalMeshComponent
  Components.Add(LeftShouldPadSkeletalMeshComponent)

  // Create the right shoulder pad skeletal mesh component
  Begin Object Class=SkeletalMeshComponent Name=RightShoulderPadSkeletalMeshComponent
    bCacheAnimSequenceNodes=false
    AlwaysLoadOnClient=true
    AlwaysLoadOnServer=true
    bOwnerNoSee=true
    CastShadow=true
    BlockRigidBody=true
    bUpdateSkelWhenNotRendered=false
    bIgnoreControllersWhenNotRendered=true
    bUpdateKinematicBonesFromAnimation=true
    bCastDynamicShadow=true
    RBChannel=RBCC_Untitled3
    RBCollideWithChannels=(Untitled3=true)
    LightEnvironment=MyLightEnvironment
    bOverrideAttachmentOwnerVisibility=true
    bAcceptsDynamicDecals=false
    bHasPhysicsAssetInstance=true
    TickGroup=TG_PreAsyncWork
    MinDistFactorForKinematicUpdate=0.2
    bChartDistanceFactor=true
    RBDominanceGroup=20
    MotionBlurScale=0.0
    bUseOnePassLightingOnTranslucency=true
    bPerBoneMotionBlur=true
    // Assign the parent animation component to the head skeletal mesh component. This ensures that
    // the pawn animates as if it was one skeletal mesh component.
    ParentAnimComponent=HeadSkeletalMeshComponent
    // Assign the shadow parent component to the head skeletal mesh component. This is used to speed up
    // the rendering of the shadow for this pawn and to prevent shadow overlaps from occur.
    ShadowParent=HeadSkeletalMeshComponent
  End Object
  RightShoulderPadSkeletalMesh=RightShoulderPadSkeletalMeshComponent
  Components.Add(RightShoulderPadSkeletalMeshComponent)
}

注意

上記のクラスでは、Anim Node Sequence (アニメーション ノード シーケンス) が定義されることによって、アニメーションをテストできるようになっています。これによって、アニメーションツリーが通常のようには働かなくなり、Anim Node Sequence (アニメーション ノード シーケンス) がクラススクリプトまたはオブジェクト (アーキタイプ内の) から取り除かれることによって、アニメーションツリーが再び機能するようになります。

関連テーマ

モジュラーポーンのプロパティ


ModularPawn (モジュラーポーン) をワールドに配置した後にプロパティウインドウを開くとすべての骨格メッシュが表示されます。

ModularPawnProperties.jpg

各骨格メッシュオブジェクトを展開し、骨格メッシュを適切に設定します。親骨格メッシュコンポーネントは、Anim Tree Template (アニメーションツリー テンプレート)、 Physics Asset (物理アセット)、AnimSets (アニメーションセット) のセットをもつ必要があります。この例では、Head Skeletal Mesh (頭の骨格メッシュ) オブジェクトがこれらすべてをもっています。

ModularPawnSettingProperties_A.jpg

各骨格メッシュを設定すると、エディタに表示されます。

ModularPawnSetSkeletalMeshes.jpg

親骨格メッシュコンポーネント (Head Skeletal Mesh) は、Anim Node Sequence (アニメーション ノード シーケンス) をアニメーション オブジェクトに設定します。[Animations] (アニメーション) タブを展開すると、Anim Node Sequence (アニメーション ノード シーケンス) が表示されます。Anim Seq Name (アニメーション シーケンス名) を、Anim Sets (アニメーションセット) 配列内にあるアニメーションに割り当てます。これによって、エディタ内にある骨格メッシュコンポーネントが更新されます。アニメーションを見るには、PIE を起動します。

ModularPawnSettingAnimationProperties.jpg

親骨格メッシュコンポーネント (Head Skeletal Mesh) の平行移動、回転、スケールは、子骨格メッシュコンポーネントに影響を与えます。骨格メッシュコンポーネントが衝突シリンダー内に収まらない場合や、骨格メッシュコンポーネントがポーンの回転に対して正しい方向に向いていない場合、骨格メッシュコンポーネントが小さすぎる場合は、平行移動、回転、スケールを調整します。子骨格メッシュコンポーネントの平行移動、回転、スケールを調整することも可能です。ただし、これらは親の設定が基準となります。

ModularPawnSettingPrimitiveComponentProperties.jpg

関連テーマ

Unreal AnimSet エディタ


モジュラーポーンを PIE を起動することなく視覚化するには、Unreal AnimSet エディタ内で行います。Extra Mesh # のフィールド (赤いフィールドによって強調表示されている) を設定することによって、複数のメッシュを同一の骨格とアニメーションに割り当てることができます。この例では、Lauryrn のメッシュの大部分が割り当てられています。ただし、ブーツを割り当てるだけのスロットが充分にはありませんでした。

ModularPawnSettingTheExtraMeshInAnimSet.jpg

追加メッシュを設定した後に、[Anim] タブをクリックしてアニメーションのリストを表示します。アニメーションを選択して再生します。すべての骨格メッシュがアニメートする様子が見られます。

ModularPawnPlayAnAnimationToTest.jpg

関連テーマ

いつ使用するか


骨格メッシュ上に物を付属させる方法は他にもあります。ソケット アタッチメントを使用するというものです。そこで、問題となることは、いつソケット アタッチメントを使用して、いつ本方法を利用するかということになります。その答は、アニメーションを同期させる必要があるときということになります。この例では、すべてのメッシュが同期して 1 つのポーンとして見える必要があります。ただし、ショルダーパッドはソケット アタッチメントによっても可能です。

関連テーマ