# Help with trig and stuff please

### » Thu Sep 17, 2009 2:21 pm

I'm fine with trig on paper, but I somehow have a mental block trying to apply it to my game, so maybe you guys can help

What I need is best summed up in this diagram:

In other words, the X and Y of the spot 30 (for example) pixels above the plane, but 'up' is the direction of the plane's floor to roof rather than ground to plane

So basically I need what to put in the X and Y fields of 'add force towards'.
Hope you can help
B
2
S
2
G
3
Posts: 193
Reputation: 1,636

### » Thu Sep 17, 2009 2:27 pm

AAaaaaand I seem to have figured it out (with the help of Hempuli on IRC) about ten seconds after I post.

Well, may as well make sure this is the 'best way' to do it.

In X I have: Sprite.X-cos(Sprite.Angle+90)*30

In Y I have: Sprite.Y+sin(Sprite.Angle-90)*30

And 100 in Force.

Is this the best way?
B
2
S
2
G
3
Posts: 193
Reputation: 1,636

### » Thu Sep 17, 2009 6:04 pm

That is correct, yes, but this formula is actually a little simpler:

X = Sprite.X + cos(Sprite.Angle - 90) * 30
Y = Sprite.Y + sin(Sprite.Angle - 90) * 30

The only change for the Y coordinate is that "cos" is changed to "sin". Everything else stays the same.
Moderator
B
104
S
39
G
19
Posts: 1,584
Reputation: 18,167

### » Fri Sep 18, 2009 4:49 pm

Thanks.
B
2
S
2
G
3
Posts: 193
Reputation: 1,636