Convert Between Coordinate Spaces

Question for yall,

I’ve got a touch event with its own x and y coordinates. I am trying to see if that touch event is close to another UI element by comparing their coordinates. What is the best way to go about this? It seems like a touch event’s coordinates are in a different coordinate space than an entity’s getLocalPosition(). Anyone have any thoughts on this? I suppose I could convert by getting the size of the screen and normalizing based off that but I’m assuming their is a built in engine approved way to do this. Anyone have any thoughts on this?

Thanks in advance,
Jake

You can get the canvas corners of an UI element via https://developer.playcanvas.com/api/pc.ElementComponent.html#canvasCorners

I can’t remember if it takes into account of devicePixelRatio but should be easy to check