# First steps in Construct - Retrieving N Angles

### » Thu Apr 10, 2008 2:41 pm

Yep, Construct is awesome! But since I'm a newbie I'm having my share of problems accomplishing some (probably?) simple things - like ANIMATIONS.

Well, dang! After searching some more, I've found the anser in the forum - enable Animator Bar!

Nevermind, but thanks anyway!

...

It's possible to make objects rotate step-wise (N Angles setting). Is there a way to retrieve that step angle? The normal angle value still returns a value between 0-360. Any ideas? THANKS!
B
1
G
4
Posts: 5
Reputation: 1,035

### » Thu Apr 10, 2008 9:07 pm

You can do it with math.

a/n = N Step

Where a is the actual angle of the object and n is the number of angles in a step.

For instance, if your N Angles is set to 4 then the number of angles in each step is 90. If your object is at 270 degrees then:

270/90=3

If your N Angles is 8 then the number of degrees per step is 45. If the angle of your object is 225 then:

225/45=5

The result is zero-based so if your object is facing right, your N Step will be 0. So for an N Angles of 4, you'd get steps of 0, 1, 2, and 3.

It seems to me it would be easier just to compare the actual angle of the object, though.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

### » Thu Apr 10, 2008 10:27 pm

Thanks! I tried this, but I can't get it to match with the actually displayed angle, the value seems off. When facing right, the value can be both 0 and 3.

More details: I'm using the RTS movement and want to check what N angle (using 4 steps) is currently displayed.
B
1
G
4
Posts: 5
Reputation: 1,035

### » Thu Apr 10, 2008 10:38 pm

Just make your own compare and set a variable based on that. With N Angle of 4 you know that the only actual angles your sprite can be facing are 0, 90, 180, and 270. So do this:

[code:3kgbais7]
+ sprite.Angle Equal to 0
- set sprite.Value('nStep') to 1

+ sprite.Angle Equal to 90
- set sprite.Value('nStep') to 2

+ sprite.Angle Equal to 180
- set sprite.Value('nStep') to 3

+ sprite.Angle Equal to 270
- set sprite.Value('nStep') to 4
[/code:3kgbais7]

And if your sprite angle = 360 then manually set it to 0.

But like I said before, it would be easier to just compare the angle directly. You're just making an extra step for yourself by translating it into a single digit. I don't see the point in it (unless you have a really good reason).
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

### » Thu Apr 10, 2008 10:57 pm

Using a mix of what was suggested by deadeye and my own approach, I got this ... it may not be what you're trying to get, but I gave it a shot.

http://www.mediafire.com/?dmlge0yn2tj
B
2
S
2
G
5
Posts: 391
Reputation: 2,432

### » Fri Apr 11, 2008 6:37 am

deadeye: Thanks, but when using the RTS movement, the angle can be anything between 0 and 360, not just the 4 steps, so comparing like that won't help much (that was the first thing I tried).

Jeswen: That seems to work just fine. Thanks!
B
1
G
4
Posts: 5
Reputation: 1,035

### » Fri Apr 11, 2008 8:40 am

[quote="Bamboo":1ccbf2i0]deadeye: Thanks, but when using the RTS movement, the angle can be anything between 0 and 360, not just the 4 steps, so comparing like that won't help much...[/quote:1ccbf2i0]

Now I'm confused. What am I missing here? Does N Angles not work with RTS or something? (I haven't been able to test anything because my girlfriend has been on my computer literally all damn day )
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

### » Fri Apr 11, 2008 9:08 am

The object displays the N angles properly but the angle value does not return the actual N angles, you get the whole 0-360 spectrum instead. Might be because of the RTS movement.
B
1
G
4
Posts: 5
Reputation: 1,035

### » Fri Apr 11, 2008 9:23 am

Okay, so... if you set N Angles to 4 on an RTS object, it can only face in four directions, right? That would be 0, 90, 180, and 270. Is that what's happening?
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

### » Fri Apr 11, 2008 9:31 am

Yep, the facing only in 4 directions works, but if you try to get the angle you get anything between 0-360 depending on the angle of the RTS movement.
B
1
G
4
Posts: 5
Reputation: 1,035

Next