# Moving point along the vector

I'm making a video game in which a ball is moving towards a player. So, I have a point $P$ describing the point where the player is, and a point $B$ describing where the ball is. I know that we can represent the direction from $B$ to $A$ as a vector.

I want to move the ball a small amount towards the player, along the direction of this vector. Is there a simple way to determine the new coordinates of the ball?

• Where exactly are you running into problems? There's many ways to do this, but it depends on how computationally efficient you want the solution... Mar 18, 2013 at 1:11
• I just want to move the collision point small distance in the direction of the player. Is there a way I can move the point along the vector? Mar 18, 2013 at 1:14
• I've made substantial edits to this question, in hopes of triggering a reopoen vote. Because the question is 4 years old and my answer was accepted, I believe it is ok to take some liberty in interpreting the original post for clarity's sake. Apr 22, 2017 at 1:15

Let's say you have a vector $\vec P = [P_1, P_2, P_3]$ that represents the point's location in space. Another vector, $\vec B = [B_1, B_2, B_3]$ represents the ball's (or bullet's or whatever) position in space.
The vector $\vec {BP}$ between the two is: $$\vec{BP} = \vec P - \vec B = [P_1 - B_1, P_2- B_2, P_3-B_3]$$
So, if you want the ball to move all the way to the player, you would say: $$\vec B_{new} = \vec B + \vec{BP}$$
Or, if you want the ball to move only $1/100$th of the way to the player, you would say: $$\vec B_{new} = \vec B + \frac{1}{100}\vec{BP}$$
In general, to move some small $\epsilon$ to the player: $$\vec B_{new} = \vec B + \epsilon\vec{BP}$$
• @BadSniper Yep. :) Since you're new here, I though I'd let you know that you have the option to accept an answer by pressing the green checkmark to its right. This gives 15 reputation points to the answerer, and 2 points to the asker. Mar 18, 2013 at 1:43