Character customization with extra attachments?

I’ve been trying to build a character customization system for my game for weeks now, and I’ve had no luck whatsoever. First of all, I can add a dozen SkeletalMeshComponents and use SetMasterPoseComponent and it works just fine, but I want to combine my base mesh into one draw call, because it uses the same material. Either FSkeletalMeshMerge is really buggy, or there’s some sort of asset requirements to make it work that I’m not aware of. I’ve got nothing but random flickering geometry from it so far Skeletal mesh merge broken? - Character & Animation - Epic Developer Community Forums.

Also, I want to be able to attach long hair, skirts, capes, etc. which will need extra bones in order to drive the animation. I tried the master pose component, but all the extra bones that were added to the skeleton for the long hair end up at the origin of my model and just stretch the hair mesh out until it’s unrecognizable. Then I tried to write a custom UAnimInstance that would copy the bone transforms, but overriding NativeEvaluateAnimation doesn’t even do anything.



void USubMeshAnimInstance::NativeInitializeAnimation()
{
	Super::NativeInitializeAnimation();

	AShooterCharacter* PawnOwner = Cast<AShooterCharacter>(TryGetPawnOwner());
	if (PawnOwner)
	{
		SourceMesh = PawnOwner->GetMesh();
		TargetMesh = GetOwningComponent();
		if (TargetMesh)
		{
			ParentAnimInstance = TargetMesh->GetAnimInstance();
		}
	}
}

bool USubMeshAnimInstance::NativeEvaluateAnimation(FPoseContext& Output)
{
	bool Result = Super::NativeEvaluateAnimation(Output);

	if (!SourceMesh || !TargetMesh)
	{
		return Result;
	}

	TArray<FName> Bones;
	SourceMesh->GetBoneNames(Bones);

	for (FName BoneName : Bones)
	{
		int32 SourceBoneIndex = SourceMesh->GetBoneIndex(BoneName);
		int32 TargetBoneIndex = TargetMesh->GetBoneIndex(BoneName);

		Output.Pose.Bones[TargetBoneIndex].SetFromMatrix(SourceMesh->GetBoneMatrix(SourceBoneIndex));
	}

	return Result;
}


Is there something I’m missing? Or is Unreal 4 just not designed with character customization in mind? FSkeletalMeshMerge doesn’t seem to work, and it doesn’t seem as if it’s possible to add bones to a skeleton in order to drive long hair and other extra parts.

EDIT 1: Just tried using USkeleton::MergeAllBonesToBoneTree to get the extra bones to animate. I also tried seeing what would happen if i used the mesh with the extra bones as the master pose component, and it worked better. This still doesn’t help with character customization though because I need to be able to attach extra bones at runtime, so I tried seeing if manually looping through and calling UnHide() on all the bones would help and it didn’t. Neither did setting bRequiredBonesUpToDate = false;

EDIT 2: Now I tried to see what combinations of parts produce what results.
Arms+Torso: 16619 polys (works)
Eyes+Legs+Head: 14088 polys (works)
Everything: 30707 polys (broken)
Head+Arms: 17548 polys (broken)
Torso+Legs: 11859 polys (broken)
It doesn’t seem to be polycount related.

EDIT 3: Tried creating a simple chopped up test cube skinned to one bone and merged all the pieces to see if that worked. It did, so I exported a version of my character skinned to only one bone, and all parts merged correctly. Whatever is going on it must be something with the skeleton. Anyone have any ideas what could cause skeleton merging errors?

hello
Have you tested to set the stretched bones in the Bone Translation from Animation to Skeleton?

No, I don’t even have animation on it yet. I’m just trying to get it to even work in the reference pose right now. I tried going to the mesh with the extra bones and running Asset->Update Skeleton RefPose but that didn’t work either.