Line Tracing ( Confusion ) Unreal Crashes

hi everyone!
i have a confusion !

i’m using Unreal 4.20.2

This works! as it is exactly in the video.

FHitResult Hit;

**AActor* HittedActor= Hit.GetActor();**

if(HittedActor)
	{
            UE_LOG(LogTemp, Error, TEXT(" ray cast %s"), *(HittedActor->GetName()));
           }

But this does not work! UE Crashes when i press play after this.
rather than creating a variable for AActor* , i directly placed the actor’s name in the FString.

FHitResult Hit;

FString hittedOjName = Hit.GetActor()->GetName();

UE_LOG(LogTemp, Error, TEXT(" ray cast %s"), *(hittedOjName);

can you tell me what i’m doing wrong here?

Privacy & Terms