Find the area between 2 angles excluding deadzone

Get help using Construct 2

Post » Mon Feb 29, 2016 5:38 am

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...
Image

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.
Image

I'm sure I'm just missing something very simple, but any help would be greatly appreciated.
Be sure to check out my Metroidvania game, A Hole in the Earth
B
59
S
24
G
3
Posts: 359
Reputation: 5,683

Post » Mon Feb 29, 2016 9:05 am

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.
Using R243 for all examples
B
69
S
20
G
6
Posts: 379
Reputation: 9,699

Post » Mon Feb 29, 2016 1:36 pm

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
Image Image
B
22
S
13
G
130
Posts: 869
Reputation: 67,816

Post » Mon Feb 29, 2016 5:00 pm

Thanks @emoaeden and @MadSpy!
I'll check out your examples as soon as I get home from work,
Be sure to check out my Metroidvania game, A Hole in the Earth
B
59
S
24
G
3
Posts: 359
Reputation: 5,683

Post » Tue Mar 01, 2016 4:25 am

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...
Image

Hopefully between our combined knowledge other people wont get stuck on the same issue. :)
Be sure to check out my Metroidvania game, A Hole in the Earth
B
59
S
24
G
3
Posts: 359
Reputation: 5,683

Post » Tue Mar 01, 2016 8:37 am

Hey ryanrybot, :)

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. :)
https://www.scirra.com/manual/126/system-expressions
B
26
S
17
G
8
Posts: 323
Reputation: 6,021

Post » Tue Mar 01, 2016 4:11 pm

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.
Be sure to check out my Metroidvania game, A Hole in the Earth
B
59
S
24
G
3
Posts: 359
Reputation: 5,683


Return to How do I....?

Who is online

Users browsing this forum: Demkamen and 13 guests