Can't retreive label - only getting 'ID name'

Hi - this isnt urgent - i’ve decided to give up on it but I’d like to know what people think the problem might be. I had a little quirk whilst i was watchign this video.
I have a compoent, and an fstring, and I want to populate the Fstring with the ‘label name’ of the parent actor.
Fstring ThisActorName = “NOTSET”;
ThisActorName = ThisActor->GetActorNameOrLabel();

the FString ends up being: StaticMeshActor_41, instead of say, “myMovingWall”.
I always get the ‘ID name’ and not the label, even if i use “getLabel”.

— Of note: —
I’m using Visual Studio Community Edition 2022,
i’ve set my solution to : ‘Development Editor’


I suspect the problem was due to my solution in Visual Studio, i tested with setting the solution to ‘Development’ and it made no difference. I’m not at all familiar with what all the solutions are for and what they do.


“Returns this actor’s current label. Actor labels are only available in development builds.”


Lol the massive font was by mistake sorry.

You just need newlines between the ---. Also what is ThisActor?

Thanks for answering!

Sorry that wasnt my exact code - i was mocking up what i’d implemented.
ThisActor was a pointer to the parent actor of the component that this code resided in. Which i obtained by using GetOwner() previously.


update : In order to answer your question i reimplemented the code and its now performing as expected. I dont know why it is fine now?

I have this runnign in tick of an actor component:
UE_LOG(LogTemp, Warning, TEXT(“ActorNameorLabel:%s”), *GetOwner()->GetActorNameOrLabel());

I’ve attached an image to indicate what i’m seeing in unreal now that its working.
in yellow are the areas of interest - and in red is the value that i was getting by mistake previously.

Sorry i’m still learning how to properly use the formatting features of this website i think i foudn the codeblocks feature:


// Called every frame
void UCOMP_Mover::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
	Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
	if (ThisActor!= nullptr && MoveIt)
	{
		FV_Location_Current = GetOwner()->GetActorLocation();
		ThisActor->SetActorLocation(FMath::VInterpConstantTo(FV_Location_Current, FV_Location_Target, DeltaTime, InterpSpeed));
		
		if (FVector::Distance(ThisActor->GetActorLocation(), FV_Location_Target) <= 0)
		{
			MoveIt = false;
		}

		UE_LOG(LogTemp, Warning, TEXT("ActorNameorLabel:%s"), *GetOwner()->GetActorNameOrLabel());
	}

	// ...
}

Now i’ve remembe3red about the code formatting - next time i’ll post the code block and attach an image.

Are you saying things are still working now or it’s stopped and has gone back to printing the name?

As an aside, it’s strange that you have a mix of ThisActor and GetOwner() if they’re supposedly the same thing. Also the mix of PascalCase and Pascal_Underscore, Unreal doesn’t use underscores for names like that.

Yes sorry its now behaving as expected. I dont know why though. Ultimatley I dont recall changing anything at all.
(just noticed the button to mark it as resolved - i’ll mark it as complete - thanks)

Haha yeah you’re right about both things. - i’m aware of those two issues i just struggle with them.
Both are due to my previous study of c++ and also my exposure to various other programing languages with thier own style guides.

Those two combined make me a little inconsistently fussy about efficient code and also gives me a confused coding style lol.

When i follow the instructor i try to follow what they type exactly - and then i pause the video and go off the rails a little bit. - i dont like ambigous references in code so sometimes its hard to read.
(i’m always frustrated when i cant tell if i’m looking at a member function or a call to some other parent or library – any tips on knowing which is which would be appreciated)

Infact i’ve made such a mess of the code in this project that i’ll have to refactor it pretty heavily - but for now i’ve decided to hold my progress in the videos and i’ve created a fresh c++ project and i’m currently trying to implement everything i’ve learned up to this point withotu checkign the videos.

For anyone interested Unreal has a style guide here:
(hopefully you’ll be better at following it than me!) :slight_smile:

1 Like

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

Privacy & Terms