# Working out a reversed magnitude of a vector without affecting the angle

Ok, this may be basic vector maths, so apologies. Then again, this may also be impossible. I hope to be informed.

Basically, I’m trying to add together a number of vectors (they represent the positions of enemies), to create one big vector (a threat vector I’m going to use in the AI) … that bit would be simple, something like:

``````foreach (GameObject enemy in enemies) {
threatVector += (transform.position - enemy.transform.position)
}
``````

Apart from the issue that I want the smaller the magnitude (the closer the enemy) to create a larger vector.
As such I want to create some form of reversed magnitude, i.e. 50 - magnitude, but keep the overall angle the same.

Confused. Thanks for any pointers.

I know I may be answering my own question here, but could I reduce the vector using something like threat.Normalize() and then apply that to a new magnitude, 50 - orignalMagnitude?

You could multiply each vector by 1/length². This would give you a hyperbolic dependence of the distance, the closer, the higher (infinity at zero, which means error, so you would have to test if the distance is zero ;)).