unreal get eobjecttypequery cpp´

To get the EObjectTypeQuery for an Unreal object in C++, you can follow these steps:

  1. Import the necessary headers:
#include "Engine/EngineTypes.h"

This header file contains the definition of the EObjectTypeQuery enum, which is needed to specify the query type.

  1. Declare a variable of type EObjectTypeQuery to store the query type:
EObjectTypeQuery ObjectType;

This variable will hold the desired query type for the Unreal object.

  1. Set the value of the ObjectType variable to the desired query type:
ObjectType = EObjectTypeQuery::ObjectTypeQuery1;

Here, ObjectTypeQuery1 is just an example. You can choose from various predefined query types such as ObjectTypeQuery1, ObjectTypeQuery2, etc., or define your own custom query types.

  1. Use the ObjectType variable in the appropriate Unreal function that requires an EObjectTypeQuery parameter:
UWorld* World = GetWorld();
TArray<FHitResult> HitResults;
FCollisionObjectQueryParams ObjectQueryParams(ObjectType);
FCollisionQueryParams QueryParams;
bool bTraceComplex = false;

FVector StartLocation;
FVector EndLocation;

bool bHit = World->LineTraceMultiByObjectType(HitResults, StartLocation, EndLocation, ObjectQueryParams, QueryParams);

In this example, we are using the LineTraceMultiByObjectType function to perform a line trace against objects of the specified query type.

By following these steps, you can use the EObjectTypeQuery enum to specify the desired query type for Unreal objects in C++.