GSC reference › Built-in
VectorNormalize()
Built-in (engine)
Server + client
Math
Returns a normalized copy of this vector
Signature
VectorNormalize(<vector>)
Parameters
| Name | Required? | Details |
|---|---|---|
| vector | Required | The vector to normalize |
Example (from Treyarch's docs)
difference = VectorNormalize(end - start)
Real uses in BO3's scripts
Called 515 times in the decompiled scripts. A few, zombies first:
- scripts/zm/_art.gsc, line 232
dir = vectornormalize(anglestoforward(players[0] getplayerangles())); - scripts/zm/_electroball_grenade.gsc, line 226
forwardvec = vectornormalize(anglestoforward(self.angles)); - scripts/zm/_fx.gsc, line 151
fxpos2 = vectornormalize(fxpos2 - fxpos); - scripts/zm/_zm.csc, line 1249
forward = vectornormalize(end_pos - start_pos); - scripts/zm/_zm.gsc, line 7052
away = vectornormalize(self.origin - player.origin);
Related built-ins
- GetNormalizedMovement()Get the player's movement normalized
- GetNormalizedCameraMovement()Get the player's camera movement normalized
- Int()Casts a floating point number or a string to an integer
- RandomFloatRange()Returns a random floating point number r, where min <= r < max
- DistanceSquared()Returns the squared distance between two points - this is cheaper than the actual distance as it doesn't involve a square root
- RandomInt()Returns a random integer between 0 and max-1 inclusive
- RandomIntRange()Returns a random integer r, where min <= r < max
- AnglesToForward()Returns the forward vector corresponding to a set of angles.
- Abs()Returns the absolute value of a float
- Distance2DSquared()Returns the squared distance between two points, ignores height difference.
- Distance()Returns the distance between two points
- VectorDot()Returns the dot product of two vectors
New to GSC?
Start with the basics, or paste a compile error to get the fix.
Built-in descriptions, parameters and examples come from Treyarch's BO3 mod tools docs. Usage links point at shiversoftdev/t7-source (decompiled BO3 scripts).