How can I play a blend space 1d from code?

Hi, I got animations to work fine from code, but I can only play Montages as far as I can see. AnimInstance.h doesn’t have anything about playing Blend Spaces, nor did I see anything in BlendSpace1D.h, BlendSpace.h, BlendSpaceBase.h or BlendSpacePlayer.h. Seeing as I can’t add Blend Spaces to Montages, I’m trying to figure out how to play a Blend Space (in particular the 1D). I see classes related to it but not sure how to use them to animate my character. Any ideas?

EDIT: Conversely, if someone knows how I can blend two animations together from code, that would accomplish the same thing.

Custom Animation Blueprint

You need a custom animation blueprint class (anim instance)

then you can create a variable that you interpolate in the code, to connect to the 1D Blend Space

In code, obtain your custom anim instance from the character

and then interpolate your custom variable which is attached to the 1D blendspace in The Animation Blueprint

UYourAnimInstance * Animation = 
  Cast<UYourAnimInstance>( Mesh->GetAnimInstance() );
if(!Animation) return;
Animation->BlendAlpha = FMath::FInterpTo(Animation->BlendAlpha,1,GDeltaTime,7);

#Wiki tutorial


My own answer here: How can I play animations strictly from C++? - Character & Animation - Epic Developer Community Forums

this’s correct answer: