Why won't this method work?

I understand how the method used in the video works, but why won’t this code do the same thing? Instead, when i go into play mode with this code, the engine crashes.

The only possible thing i could think of is that because the trace is not hitting an actor when the game starts, it has issues completing the code and printing it to the log.

Hit.GetActor() might return nullptr, so you should check that before accessing any of it’s methods

If(Hit.GetActor())
{
    UE_LOG(LogTemp, Warning, TEXT("%s"), *Hit.GetActor()->GetName())
}
1 Like

alright thank you! how would i go about this, through the debugger?

What do you mean?

It would be nice to see this added to the video as a note. The checking if “ActorHit = true”, is not optional. Without it, it will crash your project because it is constantly trying to output something in the log. If it doesn’t exist at the time it is checking (not casting on a physics body), it has nothing to output and will crash.

Privacy & Terms