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
What have I done wrong? Any ideas is appreciated. Thanks!
p.s This is how I draw the wound based on hit location.
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.
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!