# How do I find the angle between two points

Get help using Construct 2

### » Thu Aug 10, 2017 3:26 am

So I've made a little GPS like system for my program and have AI moving from point to point based on that instead of the actual coordinate system used in the construct 2 editor. How can I find the angle of the line between two points so my bots know which way to go? (the built in angle function leads to my bots getting stuck sometimes)
Edit: I've tried using the atan function but it only works for angles between 90 to 270
B
27
S
12
Posts: 222
Reputation: 2,624

### » Sat Aug 12, 2017 9:02 am

set player angle to, (a, b, c, d)
a, b coordinates of first point, and c,d coordinates of the second point
''''
B
28
S
11
G
3
Posts: 114
Reputation: 3,885

### » Sat Aug 12, 2017 10:57 am

Are the graphics of the bots lined up with the zero angle ?
In C2 that zero angle is to the right. (east)
B
33
S
18
G
29
Posts: 2,493
Reputation: 21,450

### » Sat Aug 12, 2017 8:43 pm

I can't use angle(a,b,c,d). My GPS doesn't line up with the actual points in the editor so if I use angle it won't be correct. I read that in a lot of programs there's a function called Atan2 but Construct doesn't have it and the graphics are lined up with the 0 degree position
B
27
S
12
Posts: 222
Reputation: 2,624

### » Sat Aug 12, 2017 9:01 pm

angle(x1,y1, x2,y2) is the same as atan2(y2-y1, x2-x1)
B
101
S
39
G
134
Posts: 5,591
Reputation: 85,520

### » Sat Aug 12, 2017 9:06 pm

Oh my god, I'm an idiot XD I forgot that when using atan2 you have to do the subtraction to make it into 2 variables, no wonder it wasn't working. Thank you!
B
27
S
12
Posts: 222
Reputation: 2,624