I'm trying to animate a bullet going from one place to another. First I get the angle from the source to the destination by doing
local angle = atan2(startx - endx, starty - endy) |
then I move the bullet from the source to the destination by using that angle and incrementing the distance from the source
bulletx = startx + dist * cos(angle) bullety = starty + dist * sin(angle) |
but the angle is all messed up - the bullet goes in completely the wrong direction.
As far as I can tell the units of atan2, sin and cos are the same so I don't think converting between radians and degrees is the problem. I googled getting the angle between two points and getting a position from an angle but every example I found in other languages seemed consistent with what I'm doing...
Can anyone point out what I'm doing wrong?
P#36521 2017-01-23 22:21 ( Edited 2017-01-24 11:39)