UE-91735: Attempted aggressive reference replacement

Hi,
I’m just trying to figure out the message I’m getting while saving Character blueprint. This error is:

Ensure condition failed: false [File:D:\build++UE5\Sync\Engine\Source\Runtime\Engine\Private\UnrealEngine.cpp] [Line: 16613]
UE-91735: Attempted aggressive reference replacement. ‘CharacterAccessoryEyeglasses’ would have been replaced by ‘CharacterAccessoryEyeglasses’ in ‘BP_PlayerCharacter_C_0’ for property ‘SkeletalMeshComp’

I’m working in Unreal Engine 5.1.1

What I’ve done:

  • BP_PlayerCharacter inherits from my C++ character class that inherits from ACharacter
  • There I have this declaration in .h file:
UPROPERTY(EditDefaultsOnly, Category = "Components")
TObjectPtr<USkeletalMeshComponent> MeshAccessoryEyeglasses;

and this in constructor:

MeshAccessoryEyeglasses = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("CharacterAccessoryEyeglasses"));
MeshAccessoryEyeglasses->SetupAttachment(GetMesh());
MeshAccessoryEyeglasses->SetLeaderPoseComponent(GetMesh());
  • Then I’m creating my own component (inherits from UActorComponent) by CreateDefaultSubobject and this component have TMap:
UPROPERTY()
TMap<FGameplayTag, FClothingMesh> ClothingMeshes;

where FClothingMesh is:

USTRUCT()
struct MYGAME_API FClothingMesh {
	GENERATED_BODY()
public:
	UPROPERTY()
	TObjectPtr<USkeletalMeshComponent> SkeletalMeshComp;
};
  • And I’m adding this MeshAccessoryEyeglasses pointer to this struct in this TMap

But the most strange thing is not that this error is happening. The most strange thing is that I have this working for 6 skeletal meshes for now and all was good but when I added the seventh one, this error occur but ONLY while I’m trying to change and save character blueprint. When I remove this seventh mesh from above TMap, all is working right again. All the skeletal meshes are declared and created exactly the same way. All are added to this TMap the same way. No names or tags collisions (double checked).

I have no idea why this is happening. I can’t find completly nothing about this error anywhere. Please help, you’re my only hope :wink:

OK, after many investigations I finally figure it out myself. What helps is to move adding pointers to components TMap from character class constructor to PostInitializeComponents() function in character class. Now all is working good (there are 9 meshes there already) and no matter how many meshes I have in components TMap, it all works great and I have no errors doing changes in character blueprint.

But I still don’t know why it worked with 6 skeletal mesh pointers added in constructor and no more. If this is bad method, then it should gave me this error even with one mesh added like this.
If anybody know what trigger this error and how it works and what is the right way to avoid it, please reply.

2 Likes

Wow! I’ve got similar issue - the same error. I was adding UHierarchicalInstancedStaticMeshComponents in class construction script to an AActor and the code stopped recognizing them in TMap, after I added more than 3 of them (until then, all was fine…). BP also stopped from compiling. Your solution worked for me. Thank you!

1 Like