[BUG] Crash when playing montage without AnimBlueprint (4.10.2)

Pretty simple to reproduce:

  1. Add a skeletal mesh.
  2. Create a new Animation Montage.
  3. Add this montage to an Animation Blueprint using a montage slot (I used one I created).
  4. Create a reference to an animation montage on your actor class with the skeletal mesh assigned to it. ( UAnimMontage* TestMontage;)
  5. Assign “None” for the Animation Blueprint on the skeletal mesh assigned in the actor class.
  6. Call MontagePlay from coding.

Basically, when we call montage play, it will fail inside AnimInstance.cpp at

float UAnimInstance::Montage_Play(UAnimMontage * MontageToPlay, float InPlayRate/*= 1.f*/)
{
	if (MontageToPlay && (MontageToPlay->SequenceLength > 0.f) && MontageToPlay->HasValidSlotSetup())
	{
		->if (CurrentSkeleton->IsCompatible(MontageToPlay->GetSkeleton()))

By assigning the animation blueprint, everything works 100%. While I know this may not seem like an important bug, it would be nice to have an error thrown if we forget our animation blueprint (especially since it is a hard crash from the editor). Thanks so much for your time ^^!

Hey -

What are you adding a skeletal mesh to? Are you referring to a character blueprint? Can you post the callstack and log files from the crash as well as the code you use to reference your animation and call MontagePlay?

Cheers

That’s correct. Sorry my instructions weren’t very accurate. You do need a character blueprint in order to call the montage (without the animation blueprint assigned to it). Let me drop in some screenshots and stuff to make things a bit more accurate:

I have my montage exposed to be selected within blueprints:
http://itzra.in/l2ain/share/screenshots/UE4Editor_2016-02-18_15-41-15.png

This is normally where you’d set the animation blueprint, I didn’t (I noticed the crash because I accidentally forgot to set it).
http://itzra.in/l2ain/share/screenshots/UE4Editor_2016-02-18_15-41-59.png

http://itzra.in/l2ain/share/text/Diagnostics.txt
http://itzra.in/l2ain/share/file/UE4Minidump.dmp
http://itzra.in/l2ain/share/text/crashcallstack.txt
http://itzra.in/l2ain/share/text/CodeSnippet.txt

Hopefully that makes sense. Like I said, it just needs validation to throw an error when you fire the montage off without an animation blueprint (I’m assuming because it can’t get the skeleton without the Animation Blueprint).

I followed the instructions as best as I could but I did not get a crash when calling Montage_Play(). Here are the steps I used to test:

  1. Create a new class based on Character (MyCharacter)

  2. In MyCharacter.h I added an AnimMontage pointer

    UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = “AI|Dying”)
    UAnimMontage* DyingMontage;

  3. In MyCharacter.cpp I added the call to Montage_Play in the BeginPlay() function.

    if (DyingMontage)
    {
    if (GEngine)
    {
    GetMesh()->GetAnimInstance()->Montage_Play(DyingMontage);
    GEngine->AddOnScreenDebugMessage(-1, 4.f, FColor::Red, TEXT(“MontageSetup”));
    }

    }

  4. After compiling these changes, I made an Animation Montage (newAnim) and a blueprint based on MyCharacter (MyCharBP)

  5. In MyCharBP, I set Dying Montage to newAnim and the Skeletal Mesh to the SK_Mannequin.

With this setup I added an instance of the MyCharBP to the level and played in the editor. I did not get a crash and was able to exit PIE and start again. Can you elaborate on your reproduction steps to help me understand what I’m doing differently?

Additionally can you post the callstack and log files from the crash for more information?

That sounds exactly like what I’ve done. Without an animation blueprint added to the skeletal mesh of the character. Where would I find the callstack and log files from the crash?

The callstack can be copied from the black Crash Reporter window when the crash occurs. The log files are saved inside the Project/Saved/Logs folder. After causing the crash, the most recent log file (based on timestamp) will be the most useful.

Also, can you let me know if using GetMesh()->GetAnimInstance() helps rather than accessing the mesh directly?

Were you unable to access the files in my previous post or were they not the correct ones? The callstack was directly copied and the log files were from the folder as well.

It’s all crashing when using GetMesh(). It ONLY crashes when I have it set to use an animation blueprint and the animation blueprint selected is NONE on the character mesh.

I had only noticed the .dmp and the code snippet - I did not see the other two .txt files initially and I am looking over them now. The Montage_Play function enter’s the first if() before crashing at the second if(). This leads me to believe that MontageToPlay is correctly however either CurrentSkeleton is not set properly or the GetSkeleton() call is failing. If possible, can you add a breakpoint in AIBeginDying where it calls for the montage to begin playing and then run the project in debug mode through Visual Studio? If/when the breakpoint is triggered, step through the code to find the value of Current Skeleton as well as the value returned from MontageToPlay->GetSkeleton()

Hey ,

I just stepped through everything like you asked. It seems that CurrentSkeleton is set to null (unable to the memory). I’ve uploaded a few snippets for you to look at:

http://itzra.in/l2ain/share/text/Crash2.txt

The crash occurs immediately when we try to use CurrentSkeleton-> because it has no value.

I tired running through the setup steps from earlier and noticed that CurrentSkeleton was set the same for me as well. Could you send a copy of your project so that I can test the crash directly? If you’re able to zip the project you can post it here or you can upload it to Google drive or Dropbox and send me a private message on the forms with the download link for privacy.

Sent you a PM on the forums with the link.

Hey -

You are correct that the crash is due to not having an Anim blueprint set in the “Anim Blueprint Generated Class” filed of the mesh’s details. I was able to reproduce the crash and have entered a report for investigation (UE-27594). Along with setting the animation blueprint, another solution is to change the Animation Mode to “Use Animation Asset” and the “Anim to Play” to your dying montage, then the crash will not occur.

Cheers

Awesome man! Glad to see it’s been tracked!