Converting Mouse to Custom Viewport

is there a way to convert my mouse to widget screen size :o? if that makes any sense

im useing this atm works fine in main viewport:

but when i switch to my widget the screen size is smaller how do i shrink the “Deproject screen” to world thing to adjust for my widget viewport :o?

Not sure I am getting the question right but there is already a built in function for that

If you explain what you are trying to achieve as a higher level question we can be more helpfull cause there is bunchof integrated functionality regarding ScreenToWorld detection, such as location, objects traces etc.

1 Like

I posted a video showing what im trying to achieve :o

“I want to be able to click on my client widget and have the orange square line up” xD

Im using this to create the viewport right now:

I need a WTF IS widget viewport to space video meng haha :smiley:

Is there a create viewport node im missing or out on or something ? :o

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.

Thanks mate seems legit gonna try right now :smiley: much appreciated!

This is what i got but results failed… :frowning: Is this what u ment ?

If i have padding = 0, then my main viewport with no (borders or widgets/render target) i should be able to click the same position on screen as i am in the world right?

Testing:
+I noticed that the results from the equation are almost equal to the GetMousePosition but not exact.
+I Swapped the the rendertarget and viewport around to consider for BEDMAS my bad.

Tried it like this still not getting exact mouse location in my main screen with no widgets
:confused:

Is there a way to get “Image” position off a widget :o?

so when you deproject this it should give the proper tile according to your system.

123

Omg thank you so much :D!

1 Like