- Home /

# How can you get a point on a direction,which is defined by 2 Vector 3s

Hi to all. I`m making a RTS Game an i`ve encountered a problem.

I have the position of two units(Vector3)and i want to find the point with one unit closer to the units positions from the middle point;

I know how to calculate the middle point, but HOW do i calculate the points one unit towards the units position.

I`m trying to find point1 and point2;

**Answer** by robertbu
·
Feb 11, 2014 at 07:28 PM

Given two Vector3 name unit1 and unit2:

```
var dir = unit2 - unit1;
var middle = unit1 + dir * 0.5;
var point1 = middle - dir.normalized * dist;
var point2 = middle + dir.normalized * dist;
```

Where 'dist' is the distance from the middle.

**Answer** by FrimaMickD
·
Feb 11, 2014 at 07:37 PM

This is simple.

Let's say you have your vector from Unit1 to Unit2 :

```
Vector3 unit1To2 = unit2.transform.position - unit1.transform.position;
```

You can have the length of that vector by doing this:

```
float vLen = unit1To2.magnitude;
```

You can have the unit vector (of length 1) by doing the Normalize operation:

```
unit1to2.Normalize();
```

You can find the middle point doing so, assuming unit1to2 has been normalized.

```
Vector3 middlePoint = unit1.transform.position + (unit1to2 * vLen /2.0f);
```

You can also directly have point 1 and 2 by doing this:

```
Vector3 point1= unit1.transform.position + (unit1to2 * ((vLen /2.0f) - 1.0f ));
Vector3 point2= unit1.transform.position + (unit1to2 * ((vLen /2.0f) + 1.0f ));
```

For this kind of problem you really have to familiarize with vector math, magnitude (length), Normal vectors, etc.

Doing a RTS without this knowledge will be impossible, but I wish you luck learning :)

### Your answer

### Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.