TLDR: Does anyone happen to know how I can access the final blendspace weights/samples from the UBlendSpace class?
Over the last few days, I’ve been attempting to make a distance-matching blendspace node. This is meant to be similar to a BlendSpaceEvaluator, but it will take in distance rather than time. The below picture shows the (nonfunctional) node I’ve made so far.
I’ve already made a proof of concept, the result of which is shown in the below video, and it works well, but that was without the use of a specialized node. It’s cumbersome to iterate with that approach though.
My plan is the following:
From the my custom Anim Node Behavior struct (FAnimNode_BlendSpaceDistanceMatch), grab the relevant BlendSamples determined by the UBlendSpace class, which I think are those that have a weight higher than ZERO_ANIMWEIGHT_THRESH.
From those samples, get the current play time using the DistanceCurve.
Normalize that time based on each BlendSample’s total play length.
Sum to get the weighted normalized time: WeightNormalizedTime = NormalizedTimes.[1] * BlendSample.Weight[1] + NormalizedTimes.[2] * BlendSample.Weight[2] + ... or something like that.
My current dilemma is figuring out how to get the BlendSamples and corresponding weights. From what I can tell, this information is hidden away in an FBlendSampleData struct that I can’t seem to access (unless I’m missing something).
To get the blend samples, you can use the GetSampleFromBlendInput function within the UBlendSpace class. So, for example, given a UBlendSpace* MyBlendSpace, you can get TArray<FBlendSampleData> BlendSampleData by doing the following: MyBlendSpace->GetSamplesFromBlendInput(ClampedBlendInput, BlendSampleData, TriangulationIndex, true), where the ClampedBlendInput is of type FVector and represents the parameterized position within the BlendSpace — and this can be acquired by doing FVector ClampedBlendInput = MyBlendSpace->GetClampedAndWrappedBlendInput(GetPosition()).
Essentially, to get the sample data, you could do something like the following:
FVector ClampedBlendInput = MyBlendSpace->GetClampedAndWrappedBlendInput(GetPosition());
int32 TriangulationIndex = 0; // this can be stored elsewhere
TArray<FBlendSampleData> BlendSampleData;
MyBlendSpace->GetSamplesFromBlendInput(ClampedBlendInput, BlendSampleData, TriangulationIndex, true);
I hope that helps. I do the above in my Animation Matching Suite plugin when I apply distance matching to BlendSpaces.
Yes, that sounds right. I got as far as GetSampleFromBlendInput and could not figure out how to get the current blend input vector. I’m glad you answered your old question and made it clear for me lol.
This seems like something that should be way more accessible. Thanks for the reply!