Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Suppose I have two game object located at two Vector3s v1 and v2, respectively. If I wanted to locate a position between v1 ad v2, but 3 units away from v2, how would I manage that in terms of calculating the target vector (vT)? Basically, I want object 1 to translate toward object2, so that it can play an attack animation a reasonable distance away from the combat target without being on top of it.

I calculate a vector pointing from v2 to v1:

Vector3 heading = v1 - v2;
Vector3 headingNorm = heading.Normalize();

From there, how to I "add 3 units in the direction of v1 from v2" to get the target position?

Thanks in advance!

share|improve this question
Please give your question or more meaningful title, e.g. "How to find a specific point between two others?" – Tobias Kienzler Jul 12 '13 at 7:38
up vote 10 down vote accepted

Vector3 vT = v2 + headingNorm * 3;

Be careful though, if v2 and v1 happen to be closer than 3 units away this will put you on the far side of v1. Maybe you want this to make the unit step back to make room for the attack. But then again be careful, because that means as you approach that attack point you will overshoot then correct and overshoot the otherway over and over again!

share|improve this answer
Thank you very much! – Helios Jul 12 '13 at 1:52

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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