# GetHitResultUnderCursorForObjects and EObjectTypeQuery in C++

**URL:** <https://forums.unrealengine.com/t/gethitresultundercursorforobjects-and-eobjecttypequery-in-c/421599>\
**Category:** C++\
**Tags:** object-picker, workaround, unreal-engine, UE4, CPP, question\
**Created:** [April 2, 2018, 12:43pm UTC](https://forums.unrealengine.com/t/gethitresultundercursorforobjects-and-eobjecttypequery-in-c/421599 "2018-04-02T12:43:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![SausagesSizzling](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SausagesSizzling](https://forums.unrealengine.com/u/SausagesSizzling)\
**Post date:** [April 2, 2018, 12:43pm UTC](https://forums.unrealengine.com/t/gethitresultundercursorforobjects-and-eobjecttypequery-in-c/421599/1 "2018-04-02T12:43:31Z")

</div>

There are a few questions discussing EObjectTypeQuery on the AnswerHub that were never answered but they are fairly old so I am hoping something has changed in the meantime. I am trying to use GetHitResultUnderCursorForObjects() so something like this

```
TArray< TEnumAsByte< EObjectTypeQuery > > objects;
 objects.Add(EObjectTypeQuery::ObjectTypeQuery1);

 FHitResult hitResult;
if ( GetHitResultUnderCursorForObjects(objects,true,hitResult))
{
// Do the stuff...
}

```

but how do I know which object ObjectTypeQuery1 corresponds to? Just for concreteness lets say I am trying to find HitResults for objects derived from a class called AShape. Is there any workaround for this? In blueprints you can see the list of objects so I assume it must be possible somehow…  
Thanks!

---

<div class="post-metadata">

**Author:** ![Kafumanto](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/kafumanto/32/1194651_2.png) [@Kafumanto](https://forums.unrealengine.com/u/Kafumanto)\
**Post date:** [January 2, 2019, 7:40pm UTC](https://forums.unrealengine.com/t/gethitresultundercursorforobjects-and-eobjecttypequery-in-c/421599/2 "2019-01-02T19:40:29Z")

</div>

The logic of the pointed method is based on “_collision channels_” and not directly on “_actor types_”. Here you can find more detailed information using BP (of course it applies also to C++): [https://impetus-games.com/blog/Rotating-an-Actor-towards-the-Mouse-Cursor-in-UE4](https://impetus-games.com/blog/Rotating-an-Actor-towards-the-Mouse-Cursor-in-UE4) .

For the C++ side, after having properly configured the collision channels as explained in the above link, here is an example on how to fill the input array using both predefined and custom collision channels:

```
TArray<TEnumAsByte<EObjectTypeQuery> > objTypes;

// From "common" ECollisionChannel values
objTypes.Add(UEngineTypes::ConvertToObjectType(ECC_WorldDynamic));

// From "custom" collision channels.
ECollisionChannel CollisionChannel;
FCollisionResponseParams ResponseParams;
if (UCollisionProfile::GetChannelAndResponseParams(FName(TEXT("MyChannel")), CollisionChannel, ResponseParams))
{
    objTypes.Add(UEngineTypes::ConvertToObjectType(CollisionChannel));
}
```
