Tracing beneath HUD element / Crosshair

I’m trying to get a trace of all objects beneath a large, circular crosshair element on the HUD, but I don’t know how to go about it.
The goal is to have the player smart-target anything inside this large crosshair.

My first thought would be to do a shape-trace, but this wouldn’t account for depth; the shape effectively gets smaller the further out it goes, and wouldn’t be able to match the crosshair.

I also considered performing a series of line traces out from under the crosshair, but that would leave a lot of gaps for smaller objects to slip by.

I could combine ConvertWorldLocationtoScreenLocation with GetActorBounds to see if an object’s bounding box overlaps the crosshair, but then I would need some way to reference each object on screen anyway. Since running that each frame on every object in the level would be beyond inefficient.

Is there some way to grab any object which falls within a certain space on the screen?

Never used this node but it seems to be doing what you’re after.

237477-capture.png

However, I don’t think it’s going to work for a circular shape as it’s clearly designed to cater for RTS style rectangle selection. If you’re versed in c++, consider taking it apart and see what makes it tick. Perhaps you can adopt it to your needs.

Thank you! Worst case scenario I can just change the crosshair bounds to a square/rectangle, but I think I can get a clear enough approximation by just run this 3 times over. Vertical rectangle, horizontal rectangle, and a square.

Nevermind. After some testing, this can’t be run every frame. It’s only meant to be run once as the HUD is drawn, apparently. Using it per-frame destroys performance and throws up constant error reports.

“FirstPersonHUD_C_0 Canvas Draw functions may only be called during the handling of the DrawHUD event”

I have it running off Event Tick, just printing the names of actors found.

Shame. What is the error message if you do not mind me asking?

Did you run it off EventReceiveDrawHud?

I just tested it like this:

It has to be run in the HUD’s unique event that fires every frame. It’s quite performant.

Seems to be working fine this way.

Cool, it does work. Just had to run it off the Event Receive Draw Hud event and it does exactly what I need.