Animation blueprint switch desktop-crashes engine

(version 4.12.5)

Hi everyone, I have a question I am actually pulling my hair over. In our game we have lots of different animation blueprints, which we apply on main pc for various conditions (as opposed to a master animation gigablueprint which would have tons of nested state machines). Our approach however causes engine to desktop crash at times when it’s necessary to switch ABP (not always but very often). Sometimes it helps to put delays after the ABP switch but I am not going this way since it would make the whole game unpredictable.

It boils down to this method:

UE4Editor_Engine!USkeletalMeshComponent::ApplyAnimationCurvesToComponent() [d:\build++ue4+release-4.12+compile\sync\engine\source\runtime\engine\private\components\skeletalmeshcomponent.cpp:1419]

specifically this line:
if (SkeletalMesh && InAnimationMorphCurves && InAnimationMorphCurves->Num() > 0)

My main question is:

what is a preferred way to handle this? In our game we have lots of event specific animations (as opposed to a standard simple state machine). I have a feeling that we might be doing this all wrong otherwise nobody would be able to make an actual game. :slight_smile:

I will be grateful for any advice how to approach this or for any idea how to workaround those crashes.

Thank you!

It is a bit hard to gather the necessary info without seeing a stack trace, but the ApplyAnimationCurvesToComponent() function is called from the AnimInstance, i.e. the Animation Blueprint. So the fact you switched your AnimBP with another is causing issues for the original one, which seems to still be around.

What might help is to add a 0 second (aka single frame) delay. That way there isn’t any unpredictable behavior and the previous AnimBP has time to clean up. Alternatively, you might want to see if there’s a way to stop the previous AnimBP logic before switching to a new one.

Thank you, DamirH,

unfortunately neither of those suggestions worked. :frowning: I tried both setting the animation to default state (just idle) and adding single frame delay. Crashes are still there.

I did not mean to reset the anim BP to idle - I meant to actually disable, or even destroy it. I haven’t done this myself and won’t be able to give it a shot until I get to the office but I can’t think of a different way to do this.

Hi metamorphium,

I’ve tracked down your crash in our system, but I’d like to get a decent repro internally. Are there specific AnimBPs that you’re switching from that appear to cause this more regularly? If so, is there anything unique about them that may help me reproduce this?

I’d also like to address switching AnimBPs.

When you say event specific animations, are these animations that could be covered by firing an AnimMontage?

State Machines within State Machines isn’t an unheard of thing, but typically what I see as an efficient way of working is to have separate state machines for different actions. Then you blend between them in the AnimGraph to produce the desired effect. I really wish I could post

For example, you have a Locomotion State Machine, but you do a LayeredBlendPerBone on another state machine that controls the upper body and grips for different weapons. Alternatively, you can have a BlendbyInt inside of any given state that switches to different weapon grips.

Maybe that’s not your case, but I’d definitely suggest posting on the forums to get opinions about the best way to tackle your animation system needs.

Also watch this: - YouTube

Hi ,

Thanks a lot for looking into my issue!

In my case I prefer to have ABP as simple as possible so it’s always a relatively simple state machine without any complex logic or nesting.

But! I believe I’ve tracked down the always-reproducible case.

Basically the engine always crashes if an animation is playing while you change the animation instance class. The tricky part is that for Unreal the
ApplyAnimationCurvesToComponent is being called even after the animation is no longer playing. This nondeterministic amount of time is basically where the crash occurs because my game thinks that the animation is over and I can switch but it is not.

My workaround is that I’ve added a small delay (0.5 s) after the animation is over before I switch the Animation Blueprint and the crash went away. I also alternatively tried to stop the animation but it didn’t help (respectively, even after calling the manual Stop, I still have to put there that delay).

If I would repair this, I would probably make sure that Set Anim Instance Class terminates all animations and waits for a proper closure. But I didn’t look deep enough into the engine code yet. :frowning:

Hey metamorphium,

Any way you can reproduce this in a Third Person Template project? I’m having trouble getting this to occur on my end. If you get it to work, you can either send screenshots or the project itself.

Adding delay of 0 before Set Anim Instance Class helped me out in my case. Thank you DamirH.