Another way to get actor name?

So in practice of printing hit actor name, which has resulted

AActor* HitActor = HitResult.GetActor();
UE_LOG(LogTemp, Display, TEXT(“Hit : %s”), *HitActor->GetActorNameOrLabel());

in lecture(08:00).

My attempt was

FString HitActor = HitResult.GetActor()->GetActorNameOrLabel();
UE_LOG(LogTemp, Display, TEXT(“Hit : %s”), HitActor);

and got error while build.

I’m curious of what is wrong.

1 Like

You need to dereference the FString to get it as a const TCHAR*

It’s the same way just with a intermediate variable.

2 Likes

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

Privacy & Terms