Blend two animations in C++

Hi,

I want to play two AnimSequences one after another. Obviously second animation playing immediately discarding first one. I want to interpolate/blend from Animation_1 to Animation_2.

.h file

UPROPERTY(EditAnywhere, Category="SomeCategory")
UAnimSequence* Animation_1;

UPROPERTY(EditAnywhere, Category="SomeCategory")
UAnimSequence* Animation_2;

.cpp file

bool bLoop = true;
GetMesh()->PlayAnimation(Animation_1, bLoop);
//After some delay (say 10 seconds)
GetMesh()->PlayAnimation(Animation_2, bLoop);

Solutions i tried:

  1. Created AnimMontage with two/more animations and tweaked blend parameters. I didn’t see any blend between animations
  2. AnimBlueprint & Blendspaces - can’t use, because animations are loaded during runtime (i.e dynamically)
  3. Alternate solution is to script AnimBlueprint in C++, that is adding nodes and state machines via c++, don’t know if it makes sense, if it is then how?

If you think BlendSpace1D is good solution please let me know how to assign animations to BlendSpace1D in C++
Both C++ and Blueprint solutions are welcome

Thanks in advance!

When you work with CPP only, you loose the ability to do blend. You can code the “event graph” part of the animation blueprint, but not the animation graph.

What you can do instead is create a state machine that blends between 2 montages that are coming from a variable and you set those up in CPP. You can also do curve based animations.

Check out Advanced Locomotion System on marketplace, look for ASL v3 CPP on google and you find sample codes for both.