# How do I calculate Position (X,Y) using Angle and Distance ?

Get help using Construct 2

### » Fri May 09, 2014 10:38 pm

How do I calculate Position (X,Y) if I know the Angle and Distance ? I know it has something to do with sin and cos, but trigonometry was never one of my strong points
B
49
S
15
G
6
Posts: 536
Reputation: 7,199

### » Sat May 10, 2014 1:56 am

Here's the equations for that.

X=distance*cos(angle)
Y=distance*sin(angle)

But this is an angle and distance from the origin (0,0), usually you want the position (x,y) an angle and distance from another position (x0, y0).

X=distance*cos(angle) +x0
Y=distance*sin(angle) +y0
B
95
S
34
G
128
Posts: 5,495
Reputation: 81,678

### » Sat May 10, 2014 2:02 am

TGeorgeMihai wrote:How do I calculate Position (X,Y) if I know the Angle and Distance ? I know it has something to do with sin and cos, but trigonometry was never one of my strong points

What do you need it for? Was thinking that there might be an easier way, if people knew what you wanted to use it for,
B
45
S
12
G
3
Posts: 1,209
Reputation: 7,537

### » Sat May 10, 2014 4:26 am

@R0J0hound
Thank you for your help. In the meantime I've found this thread and adapted after it, but is good to know I was on the right track

@nimos100
Looks that I lived under a rock in the past months since only recently I've found the [Behavior] LiteTween which helps me skip a lot of math, events and time

I needed to know this formula since I am working with the Bullet behavior. Here are my events (kind of messy at the moment ... I will try to make them cleaner later):
B
49
S
15
G
6
Posts: 536
Reputation: 7,199

### » Sat May 10, 2014 4:38 pm

Wow, math! Thanks
composer - multimedia artist
www.eli0s.com/en/
B
69
S
27
G
6
Posts: 1,146
Reputation: 10,379

### » Sat May 10, 2014 7:18 pm

I've got rid of the variables and made it as an universal Function (with parameters) for the player getting hit
B
49
S
15
G
6
Posts: 536
Reputation: 7,199

### Who is online

Users browsing this forum: Google [Bot], JMTook and 11 guests