Reading Bullet.AngleOfMotion value

Discussion and feedback on Construct 2

Post » Sun Oct 21, 2012 7:44 pm

Hi,

Is Sprite.Bullet.AngleOfMotion supposed to return a number between -180 and 180?

Sprite.Angle returns a number between 0 and 360.

I just think it's a bit confusing, I kinda expected it to return a value between 0 and 360. If it is supposed to do this then please mention it in the manual. :)

Example capxsoren2012-10-21 19:49:02
B
31
S
6
G
1
Posts: 19
Reputation: 3,828

Post » Sun Oct 21, 2012 10:20 pm

Is it especially important? An angle of -90 is mathematically equivalent to an angle of 270.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Post » Mon Oct 22, 2012 6:12 am

Yes, I understand that. But if you want to check if AngleOfMotion > 270 you have to check if AngleOfMotion is > -90. That's not a problem in itself unless it's not mentioned anywhere that AngleOfMotion is a value between -180 and 180.. :-)soren2012-10-22 06:13:57
B
31
S
6
G
1
Posts: 19
Reputation: 3,828

Post » Mon Oct 22, 2012 6:48 am

Oh cool, that's good to know.
B
134
S
65
G
16
Posts: 1,766
Reputation: 19,190

Post » Mon Oct 22, 2012 1:33 pm

@soren - you should never make angle comparisons like that, because it doesn't understand the fact different angles are mathematically identical. Rely on the 'is clockwise' condition instead.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Post » Mon Oct 22, 2012 6:35 pm

You can convert it to 0-360 like so:
(Sprite.Bullet.AngleOfMotion + 360) % 360
B
79
S
24
G
54
Posts: 4,747
Reputation: 40,757

Post » Mon Oct 22, 2012 6:39 pm

@Ashley, but 'is clockwise' is only for the object's angle, right? There's no equivalent for Bullet.AngleOfMotion, is there?soren2012-10-22 18:40:44
B
31
S
6
G
1
Posts: 19
Reputation: 3,828

Post » Mon Oct 22, 2012 10:51 pm

For bullet behaviour you can have the sprite have an angle independent from the AOM, so using the sprite angle conditions won't help.
B
134
S
65
G
16
Posts: 1,766
Reputation: 19,190


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 6 guests