Placing UI widget centered at mouse position

I have defined an image widget in a canvas, has set its anchor centered and position 0x0.

Using the below BluePrint, I am placing this widget at mouse location, and expect the circle to be centered around the mouse. However the mouse represents upper left part of circle. How to center the circle where mouse is ?



Thanks.

In this video Ryan Laley is talking about it and doing it. Check it out:)
Hope it helps

looks like your canvas anchor is set to topleft (default) just center it.

also you can actually replace the mouse cursor with a custom widget if thats your goal

If you wanted to do it with the canvas panel, you’d need to:

image

Any reason why you’d use a canvas here?


Or subtract half desired size.

1 Like

Are you sure there is a canvas’ anchor ? Looked for it but couldn’t find.

Thanks, but when I use your 0x0 anchor, the “flower” anchor icon is in the top left, not center.
Screenshot 2023-10-04 at 20.51.08

In the end I indeed may substract half of its size, but I don’t understand the need for anchor then…

Make sure your anchor settings are like mine. Anchoring is a canvas-only features and serves a different purpose. It allows you set relative offsets. But it does work here due to its versatility.

Do note that when you add a widget to the viewport, you do so with its upper left corner in mind.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.