Converting Mouse to Custom Viewport

I tried to understand what is going on and my guess is:

  • When client clicks orange highlights are correct.
  • However when you switch to other view , which is probabyly the one with render target its not matching.
  • Since your render target size is not matching the position clicked on the viewport

Not knowing your entire systems created (seems a lot of going on) easiest way to solve it is to,

GetViewport size (XY) and divide it to RenderTarget(XY) this will give the scaling between your viewport and render target. Also since you have padding from left and right you have to compansate that to get actual location rather than a virtual.

ScalingX = RenderTargetX/ViewportX
ScalingY = RenderTargetY/ViewportY

Padding X and Y is where you place in UMG

ActualWorldPosX = (MousePos X - Padding X ) * ScalingX
ActualWorldPosY =(MousePos Y - Padding Y ) * ScalingY

Now with this you can make a trace for tiles and it should work if I get it right.

Let me know if it works or correct us further about it.