x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How can I detect a cursor hover over a circular widget?

UMG can detect cursor hovers over a widget, but as far as I know it can only detect the hovers over a rectangular-shaped widget. I need the widget to detect the hover within a circular bound, is there a way to do that?

Thanks.

Product Version: UE 4.8
Tags:
more ▼

asked Jun 24 '15 at 05:25 PM in Blueprint Scripting

avatar image

jechli
145 22 27 84

avatar image Jägermanjensen Jun 24 '15 at 06:50 PM

As of right now no there isn't, aside from making multiple buttons and tying them to the same function.

What is it exactly you're trying to do?

avatar image jechli Jun 24 '15 at 07:32 PM

I have a widget with a circle image on the hud, like so:

alt text

There is a building mechanic in our game, and I would like to only let the player build in the area within the red boundary of the circle (the pinkish-purple area), while the blue areas should not allow the player to build. The problem is, the widget also includes the square dark blue area that encompasses the circle. I would like to extract the cursor hover detection out of that dark blue square area.

circleboundary.png (11.2 kB)
avatar image Jägermanjensen Jun 24 '15 at 08:30 PM

well you can mask the image in a material so that only the red circle appears, that wouldn't fix you're hovering problem of wanting to only be able to interact with the red circle. kind of a cheap fix is you can determine the exact center of the circle, get the mouse position in 2d space and check to see if it is within bounds of the circle i.e. if the circle is 250 pixels in radius you can get the exact center position in 2d space and save it in a variable, then run a function that will get the mouse position in 2d space subtract the centers Y(base) and X(height) positions from the cursors y and x positions, get the absolute values, square them, add them, then find the square root of that value(hypotenuse) then compare if it is less than or equal to 250, if it is continue with running the function

avatar image jechli Jun 24 '15 at 11:52 PM

Yeah, I actually wanted to do it that way at first, but I have no idea how to get the size of the widget on the viewport. I know the initial dimensions of the widget, because I set them myself, but if the screen size readjusts there's no straightforward way of getting the pixel dimensions of the widget dynamically. I am looking into how I can, possibly, calculate the pixel dimensions myself (I think it has something to do with the dpi, since the actual 'desired size' never changes).

avatar image Jägermanjensen Jun 25 '15 at 01:37 AM

You may just have to assume everything to be 1080p and then when the resolution is lower just find the ratio or the 1080p control to the new ratio and multiply all your mathematical mumbojumbo with it. It's be pretty nice if it was straight forward, either that or break down your UMG menu into like 48x48 buttons each corresponding to set coordinates in the world so its as simple as select a button, then select what you want built there, assuming its a 3-D game

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question