Determining if Trace Hit World

I’m attempting to implement a melee attack for a weapon in a game. I’m doing it by performing the following trace in C++

FHitResult Hit;
GetWorld()->LineTraceSingle(Hit, SpawnLocation, EndTrace, COLLISION_TRACE_WEAPON, FCollisionQueryParams(GetClass()->GetFName(), false, Owner))

I’m trying to determine if there’s an easy way to distinguish between hits against world geometry actors and other types of actors. Previous versions of the engine had the bWorldGeometry flag in Actor but I don’t see that in Actor.h.

It looks like can manually do another trace using different FCollisionQueryParams, but I’d prefer if I could handle this using only one trace and just distinguishing the Hit->Actor by properties in some way.
What’s the best way to approach this in UE4?

Can’t you just

Cast<AStaticMeshActor>(HitResult)

or whatever to test the type of the Actor you hit?

#Test Hit.GetActor()

You can test the result of the Hit to see what type of actor you hit!

#include "Landscape/Landscape.h"

AActor* HitActor = Hit.GetActor();
if(!HitActor)
{
  //did not hit anything
  return;
}

if(HitActor->IsA(AStaticMeshActor::StaticClass()) || 
   HitActor->IsA(ALandscape::StaticClass())
){
  //counts as world geometry
  return;
}

//Character
if(HitActor->IsA(ACharacter::StaticClass()))
{
  //Hit a character!!!
  //do stuff
  return;
} 

//anything else, now do other actions

Thanks Rama, great examples here demonstrating exactly how to distinguish between different classes.

Note: For the include to work you must have “Landscape” in your MyPrioject.Build.cs

Its resolve fatal error C1083: Cannot open include file: ‘LandscapeProxy.generated.h’: No such file or directory.

Thanks!