Line Trace from HUD button location

I am trying to set up a simple line trace but I am not sure how to use the location on a button in my HUD ui as the start point. Basically I have set up my HUD with 2 buttons. One is in the center of the screen and one is directly to the right of it (Position X=500). I would like to be able to hit a button to do a line trace to what is behind the button.

I am able to do the trace from the center point but that is really only because its in the center and not by referencing the button to get its location. I was able to get my trace to her where the side box is but only when pointing directly in front with the following blueprint.


Unfortunately if I turn at all this breaks. This is the left wall (3rd person shooter demo)

I am guessing there is a way to modify the position relative to the direction the character/camera is facing, but I would think if I could use the position on the screen of the HUD element that would be better since it would be less math. I will eventually have more than 2 buttons so the cleaner I can keep this the better, but either way will work if that isn’t possible. I have just started with unreal so I apologize if this is super basic.

Hi @Sysadmin_Acct
Take a look at these two nodes, i fuond two videos too that very clear !
Get Hit Result under Cursor

Convert Mouse Location to World Space

Thanks! These are great for info. Any idea on how to convert this from cursor to button? Unfortunately the cursor will always be in the center of the screen because the screen rotates with it in my game.

I was able to get a workaround working with this, but I have only got this to work with changing the direction of the trace left/right and not up and down which I will need for my third point.

Please ignore the ConvertScreenLocationToWorldspace. I was just playing with that, but as you can see its not doing anything.

Hi @Sysadmin_Acct

I think you can get the screen location of a button using something like this

And once you get the coordinates you can try

Thanks for the info. These definitely seem useful. I ended up solving the issue with Get Viewport Size along with Deproject Screen to World. Im not 100% sure thats the best way but it seems to work.