# Generate Angle for Projectile to Follow So It's Ends Facing Downward

I am building a game within a game engine. The game is a 2D platform, where the player can move left, right, and jump/fall down. Part of the game is the presence of physical projectiles falling from the 'sky'. When these objects are created (in the sky), impulse is applied to them toward the present location of the player [Pic 1]. Please note the impulse is applied one time using the location of the player at object location, it is not constantly being applied to the location of the moving player. The projectile should move toward that location of the player, not necessarily to the location - and it does - but as it reaches its destination the object starts to curl upward [Pic 2].

I have tried several formulas for setting the angle on each tick (every frame), namely

Set Angle Toward: PlayerWasAtX, LayoutHeight
Set Angle Toward: Self.X, LayoutHeight
Set Angle Toward: If (Self.X > Self.PlayerWasAtX)
Then (Self.X - PlayerWasAtX) / 2
Else (PlayerWasAtX - Self.X) / 2
, LayoutHeight


Where PlayerWasAtX is the stored location of the player upon projectile creation, LayoutHeight is the total height of the canvas, and Self.X is the X-coordinate of the projetile.

In those examples, example 1 would curl, example 2 would keep the object straight down at all times even when falling at a curve, and iirc example 2 just acted wacky.. or it acted the same as example 1.

Any help would be appreciated. Here are my reference pictures:

• Closing and migrating: this is not a mathematics question at all.
– Willie Wong
Mar 14 '14 at 8:34

Specifically, store the previous position prev.x, prev.y somewhere. The on the next frame where you already have calcualted the new position curr.x, curr.y, you calculate the angle between prev and curr and use that for the projectile.
I don't understand the mechanism you are using but it appears to rely on X alone which is bad. The angle should be determined by x & y and relying on the current x & y and the previous ones.
• Thank you for your response. I tried your suggestion, setting the angle each frame using the angle function, inputting x1, y1 as the current coordinates and x2, y2 as the prior coordinates. The projectile just spins around furiously about its origin. I have also tried setting the angle manually, using the formula atan(deltaY/deltaX) * 180 / pi, but the projectile either stays straight down, or flips between straight down and straight up. Mar 17 '14 at 14:09