I'm trying for a week now and I really have a hard time with this one. I'm pretty sure that this is something very simple but I can't seem to find a solution. I'm making a game where the enemy is shooting arrows to the player without including air friction.

We already know the following values (just some random values):

  1. Enemy position [startPoint = (0,0)].
  2. Player position [endPoint = (20,10)].
  3. Gravity [g = 10] (In-game physics are using this value).
  4. Velocity [Vo = 25].

The question is "How to calculate the direction vector [u] using these values?".

I have already used u = 2Δ - gt² / 2Vo*t where Δ = endPoint - startPoint but it doesn't give me the correct vector which later will be multiplied with velocity.
I can see that because, by finding the angle of the vector θ = atan2(u.y, u.x) and getting back the direction vector u = (cosθ, sinθ), the vector is not the same.

After u is known, I can find the starting horizontal [Vox] and vertical [Voy] velocities and apply them to the arrow by doing:
Vox = Vo * u.x
Voy = Vo * u.y

  • $\begingroup$ You know the required x-distance to travel, the total speed ( $\mid Vo\mid$ ) , and the relationship between initial vertical speed and time before impact w/ the ground. Solve that set of equations. $\endgroup$ Sep 5, 2014 at 13:27
  • $\begingroup$ I have already done that with a target that is on the ground. The problem starts when I want to hit a target that is not on the ground, like the endpoint we have here which is y = 10 above the startPoint. I'm using positive y from the startPoint and up. $\endgroup$ Sep 5, 2014 at 13:54
  • $\begingroup$ It's the same equations, except you solve for the time to fall back to "start height + 10 meters" $\endgroup$ Sep 5, 2014 at 16:52
  • $\begingroup$ Sorry but I can't understand what you're saying. I'm not good in physics at all and I'm learning for a week now. If it's possible I would like to know the steps involved for the solution of this problem. $\endgroup$ Sep 6, 2014 at 13:27

1 Answer 1


Finally after more than a week I managed to solve the problem. Here's the solution that a lot of people are seeking (I'm sorry for the expression of the formulas):

First we find the delta vector:
delta = endPoint - startPoint = (20, 10)

There are two angles involved, the inclination angle [θinc] and the projectile angle [θproj].

The inclination angle is:
θinc = atan2(-delta.y, delta.x) = 26.56

The projectile angle is:
θproj = atan(Vo² + √(Vo^4 - g(g·delta.x² + 2·delta.y·Vo²)) / g·delta.x) = 79.69
θproj = 90 - θproj = 10.31

We add the two angles and we have our final angle:
θ = θinc + θproj = 36,87

Now we can find the direction vector:
u = (cosθ, sinθ) = (0.8, 0.6)

And we have our horizontal and vertical velocities:
Vox = Vo * u.x = 20
Voy = Vo * u.y = 15

General statement: When you're in need of a tool (mathematical or physical) to complete a job, if the tool already exists, it's better to use it than trying to build it yourself. This way you complete the job quickly and you don't mess with other fields outside yours trying to build the tool. Imagine a doctor trying to build an oscilloscope. Some guys have spent their whole life trying to build and optimize a tool, to be ready for the rest of us to use. Don't make their time seem wasted. It's our duty to share the knowledge we have to help the ones that don't have. Contribution is everything!


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.