Why does creating an FString from ActorHit causes Unreal to crash

Hey guys,

I thought I had my head around these pointers but obviously not as I keep causing Unreal to crash and having to reset my project.

Here is the code I was trying to do to save the actor that gets hit name as an FString.

AActor* ActorHit = Hit.GetActor();
	
FString ActorName = ActorHit->GetName();

In Bens solution he does this inline inside the debug log here:

if (ActorHit) 
	{
		UE_LOG(LogTemp, Warning, TEXT("Line trace hit %s"), *(ActorHit->GetName()));
	}

Why does my way of getting the FString always cause the editor to crash?

Never mind. ActorHit was returning a nullptr. just needed to move the FString inside the if (ActorHit) check.

Privacy & Terms