How to compare touch input with button location

I was doing some reading on here and saw it mentioned that at the moment touch input buttons using box colliders from blue print do not currently receive input and that a way around this is checking the touch input’s location with the location and size of the button you are trying to touch.
In the provided image, I created a function where I am comparing the input position against the position of the button and taking into account the size for the button and then if the touch’s x and y inputs and within the button’s area, return true.

Does anyone have a better way of doing this or see if I am doing something wrong? Thanks!

Here we go. I wasn’t accounting for the function coming back false and also where I was drawing my buttons, I was checking the values of the buttons before they had been fully computed.

By passing in the position of your buttons and then the size of the button from a touch input, you should be able to check the outgoing bool to see if the touch is inside of the button area. I also have just a bool called Down in But that I am setting for if the user touches and drags into a button or touches a button and drags out of it.

Your Check Input function worked beautifully to help solve an issue I was having with touch input and the HUD. I also added an interface to this setup that allows my HUD BP to report button locations and sizes to the player controller. Those two things coupled together make it so that you can make usable touch UI. Thanks for posting this!

Glad it helped

this post resolve all my problems, just use “get viewport scale”

https://forums.unrealengine.com/development-discussion/blueprint-visual-scripting/22260-umg-mouse-screen-position-problem?p=262344#post262344