UMG Button positioned wrong

Hello,

Thought I’d save myself the trouble of trial and error and ask here of those who already know:

I have two UMG buttons, I have one positioned where I want. The other is on the opposite side of the screen, the same distance from the right edge horizontally. I am using Local to Viewport node to compare the Touch location to where these buttons are, so I can use them as virtual joysticks (the engine’s built in Touch Interface does not meet my needs).

The left hand one works great, but the right hand one always gets something wrong.

I gave them both an upper-left corner anchor in the Canvas, and on Construct, I move the Right thumbstick button to be as far left of the right side as the Left thumbstick is from the left side, by taking the Left Thumbstick’s X position and subtracting it from the owning player’s viewport width.

For some reason, doing the math that way results in the Right thumbstick being just slightly right of center on the screen instead of mirroring the left thumbstick

What am I doing wrong?

I think I need to do another geometry-based coordinate conversion but I predict it will take me hours of trial and error (based on past experience) to figure out the magic combination since I don’t understand what really happens with those nodes, and I can’t access the geometry struct in a construct event.

I’ll have to move the logic to a sequence with a DoOnce on the Tick or is there some other event I can use?

SO I guess that’s two questions.

Before you do the calculations, place a Force Layout Prepass node. It kind of helps the widget guess its desired size immediately rather than during its tick. Since you’re moving some elements on Construct, the widget size may change, affecting the geometry. Not sure if it’s going to help here, though. Worth trying.

thanks I never knew about that node. I will try it. My current strategy to accomplish that was to put a delay 0ms node first but if force layout prepass has geometry pin then yay!