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

Get help using Construct 2

Post » 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 :roll:
B
49
S
15
G
6
Posts: 534
Reputation: 7,195

Post » 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
92
S
32
G
106
Posts: 5,272
Reputation: 69,455

Post » 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 :roll:

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
44
S
11
G
2
Posts: 1,182
Reputation: 6,838

Post » 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 :D

@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):
Image
B
49
S
15
G
6
Posts: 534
Reputation: 7,195

Post » Sat May 10, 2014 4:38 pm

Wow, math! Thanks :D
composer - multimedia artist
www.eli0s.com/en/
B
69
S
26
G
5
Posts: 1,146
Reputation: 9,829

Post » 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: 534
Reputation: 7,195


Return to How do I....?

Who is online

Users browsing this forum: plinkie, rayolf, Yahoo [Bot] and 7 guests