Standardized Angle of Motion

Discussion and feedback on Construct 2

Post » Sun Feb 09, 2014 5:07 pm

I've noticed that the way each method of moving an object has a completely different way of handling angle of motion.
For instance in 8-Directional movement, it measures the movement angle in an increment of 0 to 180 for downward-moving things and 0 to -180 for upward-moving things, while in the Pathfinding behavior, angle of motion is measured in 360 degrees.

Why is this?
Is this something that can be standardized?
B
18
S
5
G
1
Posts: 96
Reputation: 2,680

Post » Sun Feb 09, 2014 5:25 pm

It shouldn't be important. 270 is the same angle as -90.
Scirra Founder
B
387
S
230
G
88
Posts: 24,254
Reputation: 192,470

Post » Sun Feb 09, 2014 7:50 pm

It /shouldn't/ be important, but the only reason I noticed it was because it /was/ causing my animations to glitch.

My game involves switching between three different characters. You move the Active character using the 8-directional behavior, and the two inactive characters follow you with the pathfinding behavior.
Because of the switching, I have to make separate cases for animations for if they're moving with 8-directional or pathfinding. I determine which animation to play (up, right, left, down) by using the MovingAngle expression in each behavior.

Now, I thought I could just copy the code, because it would be the same, but it turns out I had to change the range of angles for each, since one uses a 0 to 180 and 0 to -180 scale and the other uses a 0 to 360 scale.
It wasn't a HUGE deal, but it's still weird and took a bit to figure out what was going on.
B
18
S
5
G
1
Posts: 96
Reputation: 2,680

Post » Sun Feb 09, 2014 8:18 pm

If you're making linear comparisons, you shouldn't be, because they don't respect the cyclical nature of angles. You should stick to the angle-specific conditions like 'Is within angle'.
Scirra Founder
B
387
S
230
G
88
Posts: 24,254
Reputation: 192,470


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 2 guests