The error eventually is just memory access violation when this nullptr is referenced elsewhere.
[Attachment Removed]
The error eventually is just memory access violation when this nullptr is referenced elsewhere.
[Attachment Removed]
Steps to Reproduce
In an actor class with SkeletalMeshComponent, when I set the component to reference mesh A, but set an animBP that uses skeletal mesh B, it leads to silent error in GetMesh()->SetAnimInstance() and causes a nullptr when I call GetMesh()->GetAnimInstance() which leads to an unexpected crash and no errors or warnings.
1) Have two skeletal meshes MeshA and MeshB
2) Create AnimBP that uses MeshB as the skeletal mesh
3) In a new actor class call GetMesh()->SetSkeletalMesh(MeshA);
4) GetMesh()->SetAnimationMode(EAnimationMode::AnimationBlueprint);
GetMesh()\-\>SetAnimInstanceClass(AnimBP);
5) When calling GetMesh()->GetAnimInstance(), it returns nullptr and no error or warning about mismatch of skeletal mesh between SkeletalMeshComponent and AnimBP.
[Attachment Removed]
Hey there,
Does MeshA and MeshB share the same skeleton uasset? If they do not, then you won’t be able to use that same animblueprint. At the end of SetAnimInstanceClass we call USkeletalMeshComponent::InitAnim. There we check to see if there is a skeleton mismatch and we’ll clear it if it doesn’t.
bool bBlueprintMismatch = (AnimClass != nullptr) &&
(AnimScriptInstance != nullptr) && (AnimScriptInstance->GetClass() != AnimClass);
const USkeleton* AnimSkeleton = (AnimScriptInstance)? AnimScriptInstance->CurrentSkeleton : nullptr;
const bool bClearAnimInstance = AnimScriptInstance && !AnimSkeleton;
const bool bSkeletonMismatch = AnimSkeleton && (AnimScriptInstance->CurrentSkeleton!=GetSkeletalMeshAsset()->GetSkeleton());
const bool bSkeletonsExist = AnimSkeleton && GetSkeletalMeshAsset()->GetSkeleton() && !bSkeletonMismatch;
LastPoseTickFrame = 0;
if (bBlueprintMismatch || bSkeletonMismatch || !bSkeletonsExist || bClearAnimInstance)
{
ClearAnimScriptInstance();
}
Dustin
[Attachment Removed]
MeshA and MeshB doesn’t share the same skeleton. It makes sense for the AnimInst to not work, but it doesn’t make sense to not get any errors or warning indicating that the anim inst was cleared. In our use-case the silent failure is the issue. The only way to debug what happened was to eventually check the tooltip of the Animation Blueprint to realize it’s using a different skeleton. This is especially harder when the MeshA and MeshB looks identical but just has a different skeleton, so the thumbnail will look the same.
-Harshal
[Attachment Removed]
Understood, we can do some logging in the future to better indicate this so that you don’t run into this in the future.
Dustin
[Attachment Removed]