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 ^^!
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?
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:
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).
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”));
}
}
After compiling these changes, I made an Animation Montage (newAnim) and a blueprint based on MyCharacter (MyCharBP)
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()
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:
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.
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.