# angle() expression problem D:

Get help using Construct 2

### » Tue Jan 17, 2012 9:00 pm

Okay I'm aware there's been quite a few questions relating to angles and rotation recently, but I did a search and couldn't find anything regarding this specifically...

As you probably already know, using the "angle" expression... [angle(x1, y1, x2, y2)] returns an angle based on the circle on the left.. (if x1,y1 was in the centre of the circle)

But my question is how would you go about rotating this? along with the 180 to -180 cut off point?
So if I wanted it to rotate 90 degrees for example, it would give the values shown in the second Circle.

B
28
S
8
G
1
Posts: 469
Reputation: 4,683

### » Tue Jan 17, 2012 9:23 pm

Subtract 90 degrees from angle- this should cover most cases
Outside of range? add 360 degrees

Using expression you could do this:
set var= angle(x1,y1,x2,y2) - 90
set var= (var<-180) ? var : var+360

Cross_2012-01-18 00:24:37
B
12
S
3
G
3
Posts: 73
Reputation: 2,637

### » Tue Jan 17, 2012 10:21 pm

I think it might actually be:
var = angle + 90
var = (var >= 180 ? var - 360 : var)
Scirra Founder
B
355
S
208
G
71
Posts: 22,832
Reputation: 176,760

### » Tue Jan 17, 2012 11:41 pm

I had actually tried doing this but assumed it wasn't right because what i was trying to achieve didn't work.. I brushed it aside and made the problem more complex in my head .. (but your reply made me revisit it and I found out just now it didn't work because of how i'd set up other events and vars)

..(also because i'm a dumbass)

thanks guys :)
B
28
S
8
G
1
Posts: 469
Reputation: 4,683