Get Bones Below Bone
(6/23/15)
node returns the bones that are below the given bone in the Skeleton bone hierarchy!
**My C++ Code For You!**
I used a recursive function to traverse the skeleton tree and get child bones, starting from the Starting Bone!
```
static int32 **GetChildBones**(const FReferenceSkeleton& ReferenceSkeleton, int32 ParentBoneIndex, TArray<int32> & Children)
{
Children.Empty();
const int32 NumBones = ReferenceSkeleton.GetNum();
for(int32 ChildIndex=ParentBoneIndex+1; ChildIndex<NumBones; ChildIndex++)
{
if ( ParentBoneIndex == ReferenceSkeleton.GetParentIndex(ChildIndex) )
{
Children.Add(ChildIndex);
}
}
return Children.Num();
}
static void **GetChildBoneNames_Recursive**(USkeletalMeshComponent* SkeletalMeshComp, int32 ParentBoneIndex, TArray<FName>& ChildBoneNames)
{
TArray<int32> BoneIndicies;
GetChildBones(SkeletalMeshComp->SkeletalMesh->RefSkeleton, ParentBoneIndex, BoneIndicies);
if(BoneIndicies.Num() < 1)
{
//Stops the recursive skeleton search
return;
}
for(const int32& BoneIndex : BoneIndicies)
{
FName ChildBoneName = SkeletalMeshComp->GetBoneName(BoneIndex);
ChildBoneNames.Add(ChildBoneName);
//Recursion
GetChildBoneNames_Recursive(SkeletalMeshComp, BoneIndex,ChildBoneNames);
}
}
int32 UVictoryBPFunctionLibrary::**GetAllBoneNamesBelowBone**( USkeletalMeshComponent* SkeletalMeshComp, FName StartingBoneName, TArray<FName>& BoneNames )
{
BoneNames.Empty();
if(!SkeletalMeshComp || !SkeletalMeshComp->SkeletalMesh)
{
return -1;
//~~~~
}
int32 StartingBoneIndex = SkeletalMeshComp->GetBoneIndex(StartingBoneName);
//Recursive
GetChildBoneNames_Recursive(SkeletalMeshComp, StartingBoneIndex, BoneNames);
return BoneNames.Num();
}
```
**Latest plugin download on the UE4 Wiki: (7.92 mb) **
**Victory Plugin on Media Fire**
If your browser is not updating the Wiki download page to the most recent version, you can use my alternative Media Fire download link!
Please note clicking link will not start a download instantly, it will just take you to the Media Fire file description.
https://www.mediafire.com/?g6uf9kt5ueb2upj
Enjoy!
:)