Hosting and domain costs until October 2024 have been generously sponsored by dumptruck_ds. Thank you!

normalize

From Quake Wiki

vector normalize(vector vec)

Usage[edit]

Turns a vector into a unit vector (unit vectors have a length of 1). This is useful if you need to scale in a given direction e.g. when firing a missile at a target.

Parameters[edit]

  • vec
The vector to turn into a unit vector.

Return[edit]

The passed vector as a unit vector.

Example[edit]

// Aim a missile at a monster's enemy with a speed of 512 map units/second
vector direction = normalize(self.enemy.origin - self.origin);
missile.velocity = direction * 512;