Crash on Geometry Brush with FHitResult

I’m trying to some simple LineTrace stuff so I can

1.) See if the character is looking at something (within a certain distance)

2.) See if that thing is a certain class (so that we can interact with it, pick it up, etc.)

I’m having a trouble with Step 2.
If the object IS one of the classes I’m looking for, it registers properly and all that. If, however, I’m looking at a Geometry Brush object, UE4 crashes immediately.

The culprit line is as follows:

if (HitResult.Actor->IsA(ACBaseWeapon::StaticClass()))

This conditional crashes the game, as does the line UE_LOG(LogTemp, Log, TEXT("Actor Name: %s"), *HitResult.Actor->GetName());

I assume therefore that the issue is with HitResult.Actor and geometry brushes. What work around do I need to use?

Thanks!

Found the solution. Since geometry brushes have no “root actor”, and only mesh components, getting the actor from a LineTrace returns a Null. When you try to get the name of a Null and print it, things go downhill.

Instead, if you might be looking at geometry brushes in your level, you might want to check if what you’re looking at has an actor first:

		if (HitResult.GetComponent()->GetAttachmentRootActor() != NULL)
		{
			UE_LOG(LogTemp, Warning, TEXT("We have an actor that won't crash! Actor Name: %s"), *HitResult.GetActor()->GetName());
		}