Find the area between 2 angles excluding deadzone

  • Hi everyone,

    I am putting the finishing touches a new circular IU for selecting items and am having troubles with the finer details of the navigation.

    To explain how it works, while you hold down the menu button, a circular menu appears. The direction you press the thumbstick selects the item in the corresponding position.

    I have the menu working great by selecting the area between two angles, but didn't want the item to highlight until it passed a certain distance from center.

    Currently I have the deadzone set along the x axis, but that doesn't really feel right when selecting the upper or lower items in the menu.

    Here is a rough mockup of the navigation...

    So I would like to have a specific deadzone along the y and x axis, but am having troubles figuring it out.

    Something like this would be great, where the top left item is only selected when the thumbstick is in the orange zone.

    I'm sure I'm just missing something very simple, but any help would be greatly appreciated.

  • Here is an example with angles

    Here is an example with image points I'd go this one personally

    Now I wasn't going to animate your menu (too much effort, and I'm lazy), but I changed a sprite that tracks the mouse instead. I imagine you can work out the code to show the right animation of your menu (and if not, inbox me)

    If you need more help, let me know.

  • Hi ryanrybot ,

    you want something like this : radial menu + slow motion example

    hold left trigger for menu, select with right analog, release left trigger when you have selected your weapon

  • Thanks emoaeden and MadSpy!

    I'll check out your examples as soon as I get home from work,

  • Hey emoaeden and MadSpy, I figured it out with my own equations. Thanks for your help though.

    I don't know why I didn't think of it earlier, but I just needed to find the radius of the thumbstick position.

    Here's my events...

    Hopefully between our combined knowledge other people wont get stuck on the same issue.

  • Hey ryanrybot, <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

    Just wanted to add a small additional note...

    At the top of the screen cap I noticed the LstickRadius was being set via the distance formula.

    C2 has a built in distance function that will return the distance between two points.

    It can be found as an expression in the "System" object, in the "Math" section. Or you can just type "distance" in any expression area.

    In your case, you want the radius of the stick position. Which is the distance from the stick's centered position (0,0) to the stick's current position (axisX,axisY).

    So you can use the distance function like this:

    distance( 0 , 0 , axisX , axisY )

    Granted the above example is simplified for clarity.

    Using the actual expressions for retrieving the stick positions you'd write the following.

    distance( 0 , 0 , Gamepad.Axis(0,0) , Gamepad.Axis(0,1) )

    Finally, there is also an angle(x1,y1,x2,y2) function, and an anglediff(a1,a2) function among others which can come in handy as well.

    Below I added a link to a full list of all built-in math system expressions from the online C2 manual:

    The "Math" section is a ways down the page. The "Text" section is also worth checking out. <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

    https://www.scirra.com/manual/126/system-expressions

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Wow, thanks fisholith!

    It's really nice to have these expressions explained in a practical way. I will certainly be implementing these into my game.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)