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?
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