How does "Clockwise from angle" work?

Discussion and feedback on Construct 2

Post » Fri Jul 22, 2016 12:50 am

So this isn't really a problem per se, just wondering if I'm understanding this condition correctly. The way I took it, if angle X is closer to angle Y measuring clockwise, then it's true. Consequently, the inverse of this condition tests if angle X is closer counterclockwise. Manual seemingly confirms this.

Anyway, I was using these conditions to make a sprite play different animations when it's clockwise/counterclockwise from another object, and it basically did what I wanted it to except that the conditions registered as exact opposites to what I expected. In other words, when the Sprite was facing upward and had the Object at around its 3 o'clock, it registered it as counterclockwise. When it had it around 9 o'clock, it registered it as clockwise.

Of course the solution was to simply switch the conditions, but now I'm wondering if I'm understanding these conditions correctly.
B
50
S
23
G
17
Posts: 291
Reputation: 12,432

Post » Fri Jul 22, 2016 1:37 am

Clockwise means it's a greater angle. 45 degrees is clockwise of 0 degrees. 45 degrees is counterclockwise of 90 degrees.
It's the direction the clock hands move.
Image ImageImage
B
168
S
50
G
164
Posts: 8,239
Reputation: 105,597

Post » Fri Jul 22, 2016 9:59 am

If you are looking for the smallest difference between two angles, just if, then use this expression:

anglediff(angle 1, angle 2)
B
33
S
18
G
28
Posts: 2,477
Reputation: 20,918

Post » Fri Jul 22, 2016 6:49 pm

On second thought it might not have been the fault of the conditions but the input. The angle I was testing was between two objects, i.e. angle(x1, y1, x2, y2), so perhaps it was testing the angle from the target object to the sprite, thus giving me inverse results. That'd make sense, heh.

Anyway, thanks for the replies y'all.
B
50
S
23
G
17
Posts: 291
Reputation: 12,432


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 3 guests