Extending a vector?


My problem is more of a basic vector maths problem then a scripting problem.

I want to be able to make a vector longer. I have a vector from the origin of one circle to the point of origin on another circle and I want to be able to use this vector to find an Extended vector represented in green of a different magnitude.

Does anyone have any ideas of how to do this?


Thank you in advance.

Multiply your vector by a scalar. Check this.

Vector3 extended_vector =  your_vector * (float);

To extend it to a known magnitude, you can first normalize your original vector:

Vector3 extended_vector =  your_vector * the_magnitude_you_want;

//Let the bigger circle centre position be A and smaller circle position be B and Extended

// position be C

public float float ExtenDis=5;

Vector3 normVector = (A.position-B.position).normalized;


Okay lets say bigger circle has c1 center and smaller circle has center c2. So the direction will be c2 - c1 . Now you need to normalize vector so the magnitude becomes 1 and then multiply it with any digit so it can be extended to your desired position.

Here is some code :

public Transform c1, c2, res;
public float unit;
Vector3 result;

void Start ()
	result = c2.position - c1.position;
	res.position = result.normalized;

void Update ()
	result = res.position * unit;
	Debug.DrawRay (c1.position, result);

Tweak the value of unit so you get desired results.

Hope this helps

you can simply subtract two vector threes to get direction. then simply add it to go past your second point.

var heading:Vector3;
 var howfarpas:float;
    var yournewspot:Vector3;
    heading = target.position - player.position;
    yournewspot = target.position+heading;