FPS游戏多手臂实现方式
核心代码:
TArray<FSkelMeshMergeSectionMapping> InForceSectionMapping;
USkeletalMesh* CompositeMesh = NewObject<USkeletalMesh>(GetTransientPackage(), NAME_None, RF_Transient);
USkeletalMesh* Arm = LoadObject<USkeletalMesh>(NULL, TEXT("SkeletalMesh'/Game/Players/Heather/Arm/HeatherArm.HeatherArm'"));
USkeletalMesh* Weapon = LoadObject<USkeletalMesh>(NULL, TEXT("SkeletalMesh'/Game/Weapons/AK47/AK47.AK47'"));
TArray<USkeletalMesh*> SourceMeshList;
SourceMeshList.Add(Weapon );
SourceMeshList.Add(Arm);
FSkeletalMeshMerge MeshMergeUtil(CompositeMesh, SourceMeshList, InForceSectionMapping, 0);
if (MeshMergeUtil.DoMerge())
{
CompositeMesh->SetSkeleton(Weapon->GetFPWeaponMesh()->Skeleton);
FPWeaponMesh->SetSkeletalMesh(CompositeMesh);
}
效果图:
|