CreateDefaultSubobject Seems to have stopped making unique object names

I’ve got some very basic code:

AbilitySystemComponent = CreateDefaultSubobject<UTLOKAbilitySystemComponent>(TEXT("AbilitySystemComponent")); AttributeSet = CreateDefaultSubobject<UTLOKAttributeSet>(TEXT("AttributeSet"));

Running inside my constructor for a character actor, but for some reason it seems to have stopped providing unique names as per:

UE_LOG(LogTemp, Warning, TEXT("Object Name: %s"), *AttributeSet->GetName());

Which just returns ‘Object Name: AttributeSet’ for every actor instance. It didn’t used to do this, so what may have changed so that Unreal is no longer giving them unique names?

Thanks :slight_smile:

Unreal only gives components unique names within the scope of the actor.
Within the scope of the actor, “AttributeSet” is a unique name.

We use MakeUniqueObjectName. This is deterministic btw so if you run it on the same actors / components in the same order, even on different machines, the names will be identical.

MakeUniqueObjectName | Unreal Engine Documentation

Thanks for the reply; maybe my actual problem isn’t related to this (a crash when setting the attributes), but I’m sure before today the object name was something like AttributeSet_0, AttributeSet_1 etc. I’m not 100% though, but regardless, when the code later runs I get an EXCEPTION_ACCESS_VIOLATION:

		if (AttributeSet) {
			AttributeSet->SetLevel(InitialLevel);

If I output the name of AttributeSet before this it seems to be empty for everything but the most recently created character (the player). What it seems to be doing is creating the subobjects without unique references and then replacing them with each construction; but before today it wasn’t a problem and the code is very similar to the ActionRPG sample.

Edit:

Okay yeah so it still crashes even if I give them unique names like this:

	FName AbilitySystemComponentName = FName("AbilitySystemComponent_" + FString::FromInt(GetUniqueID()));
	FName AttributeSetName = FName("AttributeSet_" + FString::FromInt(GetUniqueID()));
	AbilitySystemComponent = CreateDefaultSubobject<UTLOKAbilitySystemComponent>(AbilitySystemComponentName);
	AttributeSet = CreateDefaultSubobject<UTLOKAttributeSet>(AttributeSetName);

So it looks like I’m barking up the wrong tree with regards to the crash; I’ll keep looking - thanks!

Thanks for the reply;

I think that may fix it but it wasn’t necessary before today and every demo/marketplace project I’ve got access to doesn’t seem to need to create a unique name for subobjects created in this way.

I’d like to avoid doing it differently without at least understanding why its changed, it could be of course that the main problem (as per my other reply) is unrelated - but I don’t think so. The crash doesn’t occur if there is only one character.

I don’t know about problem with components naming, but since you talking about gas-crash without visible reasons, as a wild guess, have you copied\duplicated blueprints derived from this class? If so, check possible solutions here, paragraph 9.4

1 Like

Thanks, this sounds more like the issue I’m having - though there’s no duplication going on.

I’d like to avoid losing usage of the attribute macros as per the solution linked, so I think I’ve got it working by creating the attribute set in PreInitializeComponents as per this page

Thanks a lot for your help :slight_smile:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.