# Bullet Direction, Trigonometric Functions, and atan

Get help using Construct 2

### » Mon Mar 24, 2014 6:52 pm

I'm using atan to set the angle for a bullet. Unfortunately, it isn't behaving the way I expect. I thought that by determining the difference in x values of the target and the origin (and doing the same with the y values) I could get the opposite and adjacent sides of a triangle. From that I should be able to use atan to get an angle that references north as the 0/360 degree point. I then thought I could just subtract 90 degrees from that angle to orient the angle to Construct 2's technique of using east as the 0/360 degree point.
Well, this isn't working. My bullets seem to be going in the opposite direction they should be going. I've tried adding 180 and 270 degrees to see if that would have an affect, but it's not doing what I need it to do.
Before going down this path, I thought there'd be some action that would just let me launch a bullet towards an x,y coordinate, but I didn't see one.
Anybody know the solution?
B
5
Posts: 11
Reputation: 272

### » Mon Mar 24, 2014 7:04 pm

That was a looong text. should just have read the last two lines

There is a action called "Set angle towards position" you can use that.

Something like this:

https://dl.dropboxusercontent.com/u/2560922/mobiledev/forum/setAngleTowardsPosition.capx
B
20
S
6
G
4
Posts: 347
Reputation: 4,451

### » Mon Mar 24, 2014 7:41 pm

It never occurred to me to look outside the bullet behavior for an action that would make this happen. Thanks for the help.
B
5
Posts: 11
Reputation: 272

Return to How do I....?

### Who is online

Users browsing this forum: dioking, kelany, luckyrawatlucky and 1 guest