0
\$\begingroup\$

I am trying to display a rendered wound on the character, but I still can't figure out how to display it properly without sliding on character's body.

I'm following this link on rendering the wounds on characters but I still can't figure out why it isn't working.

This is what I have so far on rendering the wound based on hit location enter image description here

What have I done wrong? Any ideas is appreciated. Thanks!

p.s This is how I draw the wound based on hit location. enter image description here

UPDATE: So I replace WorldPosition into Preskinned Position based on the comment suggested and the sphere mask won't render at all. I thought my HitLocation must be the problem, so I get back to the linked post to understands better on how to approach this, and included some C++ as well, but all those still resulting in the same results. The sphere mask keep on sliding on the body.

The pre skinned node I added

The updated blueprint

This is the code I have been using for both callable functions above

//Recursive function to have results relative to world origin
FTransform UGestureMathLibrary::GetWorldSpaceTransform(FReferenceSkeleton RefSkel, int32 BoneIdx)
{
	FTransform BoneTransform;

	if (BoneIdx > 0)
	{
		BoneTransform = RefSkel.GetRefBonePose()[BoneIdx];

		FMeshBoneInfo BoneInfo = RefSkel.GetRefBoneInfo()[BoneIdx];
		if (BoneInfo.ParentIndex != 0)
		{
			BoneTransform *= GetWorldSpaceTransform(RefSkel, BoneInfo.ParentIndex);
			UE_LOG(LogTemp, Warning, TEXT("if parent index is not equal to zero"));
		}
	}

	return BoneTransform;
}

//Reference pose bone transform
FTransform UGestureMathLibrary::GetRefPoseBoneTransform(USkeletalMeshComponent* SkelMesh, FName BoneName)
{
	FTransform BoneTransform;

	if (SkelMesh && !BoneName.IsNone())
	{
		SkelMesh->ClearRefPoseOverride();
		FReferenceSkeleton RefSkel;
		RefSkel = SkelMesh->SkeletalMesh->RefSkeleton;
		BoneTransform = GetWorldSpaceTransform(RefSkel, RefSkel.FindBoneIndex(BoneName));
		//BoneTransform = RefSkel.GetRefBonePose()[RefSkel.FindBoneIndex(BoneName)];
	}

	return BoneTransform;
}

//Bone transform
FTransform UGestureMathLibrary::GetBoneTransform(USkeletalMeshComponent* SkelMesh, FName BoneName)
{
	FTransform BoneTransform;

	if (SkelMesh && !BoneName.IsNone())
	{
		FReferenceSkeleton RefSkel;
		RefSkel = SkelMesh->SkeletalMesh->RefSkeleton;
		BoneTransform = SkelMesh->GetBoneTransform(RefSkel.FindBoneIndex(BoneName));
	}

	return BoneTransform;
}

Am I missing something?? Thanks again!

\$\endgroup\$
  • \$\begingroup\$ You will want to bake it inside texture in the material of the character based on UV \$\endgroup\$ – ColdSteel Apr 7 at 14:38
  • \$\begingroup\$ Can you show us how you're drawing the wound based on the hit location? You're remembering to compare the distance between the wound sphere and the pre-animated position of the point you're sampling, right? \$\endgroup\$ – DMGregory Apr 7 at 16:03
  • 1
    \$\begingroup\$ There's your problem. You do not want to use world position here, but pre-skinned local position. ie, where is this point in the character's bind pose / T-Pose local space, not its animated position in the world. This is explained in the article you linked. \$\endgroup\$ – DMGregory Apr 9 at 17:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.