Can I play an animation in C++ without ANY animation Blueprint AND have it blend?

Is it at all possible to play an animation using ONLY c++. To take a mesh, pass it an animation and have it play? I also will need it to blend. That is to say I need it to transition cleanly from one animation to the next. I have been able to forego the use of an animation blueprint and just play an animation like this:

m_poMeshComponent->PlayAnimation(m_poCurrAnim, bLooping);

But this does not have an concept for transition to another animation. So if I want a clean sequence:

Idle → walk → Idle → Attack → Idle (no popping/snapping)

How would I go about this without the use of an Animation Blueprint? I have tried using the following functions and they seem to not animate without a blueprint:

m_poMeshComponent->GetAnimInstance()->PlaySlotAnimation(m_poSequenceBase, SlotNodeName, BlendInTime, BlendOutTime, InPlayRate, LoopCount);

And:

m_poMeshComponent->GetAnimInstance()->Montage_Play(m_poMontage, InPlayRate);

Just a little back story: Our game has hundreds of different Meshes. Originally when I was begining to setup the animation system for this, I put a bunch of State Logic in a state machine in the animation blueprint with the idea that I would just swap the mesh under the hood later and reuse the same state/transition logic. As I delved into this, I found that that is not part of the functionality. I see that I could replicate an AnimBP for each mesh…but that would give me hundreds of AnimBPs. If an artist wanted to tweak/add/remove a node or functionality in one of the AnimBPs, they’d have to do it for hundreds. So I decided it was best to forego the use of the Animation Blueprint system and just solve it in code. But there does not seem to be a clean or easy way that I can find to just take a mesh, play an animation on it (idle) and then when I want to play another animation (move) have it cleanly/smoothly transition between them. Montages and ‘Slot Anims’ have a concept of blend in/out, but they also take speicific slot information that says what slot they are to play on (“DefaultSlot”) and this all seems to be data setup in an Animation Blueprint that I am trying to avoid using.

Just a comment here, but, are your mesh really different or are they all pretty much the same? Like, are they all humanoid? If so, it would work best for you to have one skeletal, not one for each. That way, only one AnimBP.

If they are really different, than, I guess you would need to proceed differently…

There are really a lot of differences. I know that some things could be shared but even just in the case of 3 objects for instance: A Bird, a Fish, a person(biped). It could be that I just have a handful of these objects and opt to just use the AnimBP. Especially if a strong alternative remains elusive.

In that vein, How do I reuse the exact same AnimBP for two Biped objects? Or is it 1 animBP for object 1, and a copy of it ‘retargeted’ for object 2? Or is it literally 1 animBP for both of the objects? What if their scale differs? And the length of bones in a female vs male character?

Question: how are you initializing your animations without BP? All I see is code for with BPs. ;(

Working on something very similar now. We have a lot of animations but they are simple and only 1 per skeletal mesh (no blending needed).

Look at the top responses here:

and here:

Let me know if you have other questions.

Basically, you want to use Montage_Play because it has the smooth Blend-in, Blend-out.