GSC reference › Built-in
Length()
Built-in (engine)
Server + client
Math
Returns the length of the given vector
Signature
Length(<vector>)
Parameters
| Name | Required? | Details |
|---|---|---|
| vector | Required | A vector |
Example (from Treyarch's docs)
dist = Length(models[j].origin - center)
Real uses in BO3's scripts
Called 88 times in the decompiled scripts. A few, zombies first:
- scripts/zm/_zm_unitrigger.gsc, line 178
box_radius = length((unitrigger_stub.script_width / 2, unitrigger_stub.script_length / 2, unitrigger_stub.script_height / 2)); - scripts/zm/_zm_weap_ball.gsc, line 2156
bounceforce = length(vel) / 10; - scripts/zm/_zm_weap_castle_rocketshield.gsc, line 409
len = length(lateral); - scripts/zm/_zm_weap_elemental_bow_storm.gsc, line 697
n_length = length(v_away_from_source); - scripts/zm/_zm_weap_elemental_bow_wolf_howl.gsc, line 170
var_f35778e8 = length(var_307bab92 - self geteye());
Related built-ins
- 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.
- VectorNormalize()Returns a normalized copy of this vector
- 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
- VectortoAngles()Returns a set of angles corresponding to the given vector.
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).