Lock cursor in a circular area within a widget (help polishing script).

Hey everyone!

First post round here, so be gentle please! :stuck_out_tongue_winking_eye:

I’m trying to do (well, I actually did) a script to lock the mouse cursor in a small circular area within a widget so the player can only move the cursor to reach the buttons he/she can interact with. I think you’ll understand what I’m trying to do when you see the actual script, hopefully. To keep the post short and focused, just think of something similar to the interaction system used in the pc version of life is strange. Though, if you don’t know how that system works and need more info about the widget just let me know!

I have the following script:
(It’s a bit long so had to split it up into three pics)

Part 1:


Part 2:


Part 3:


The script is working kind of fine. The only issue -so far- is that the cursor gets a bit stuck when the angle is 0, 90, -90 or 180. It’s not a big deal actually because if you keep “pushing” the mouse, the cursor eventually moves, but it just doesn’t feel as smooth as it should. I’d like to be able to switch from one option to another smoothly, without having to move the mouse a couple of times until the cursor finally gets unstuck.

I think the problem is that I may not be using the right values in the InRange nodes to divide the circle, since the issues arise when the cursor position changes to a different fraction of the circle… Or maybe this isn’t the best approach to do it…? Anyway, any idea will be welcomed :slight_smile:
I’d prefer a blueprint approach but I can also do some basic stuff in C++, so if there’s a good way to get this in C++ I’ll be glad to hear it too.

Thanks in advance!

PS: Since this is my first post, please let me know if I’m doing something wrong.