Vector.Length
From GMod Wiki
| Function | |
| Syntax | Vector:Length( ) |
| Description: | |
| Returns the distance from 0, 0, 0 to the vector. | |
| Returns: | Float |
| In Object: | Vector |
| Realm: |
|
| BBCode Link: | [b][url=http://wiki.garrysmod.com/?title=Vector.Length]Vector.Length [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] |
Examples
| Description | Get a vector's length |
|---|---|
| Used on | |
| Code | print("Vector length is " .. Vector( 100, 0, 100 ):Length()) |
| Output | Vector length is 141.42135620117 |
Additional Notes
- All vectors start at 0, 0, 0. The end of the vector is the x,y and z coordinates it holds.
- This is the same thing as doing this:
Vector:Distance(Vector(0, 0, 0))
- It is computationally expensive to get the length of a vector. If you're only using the length for comparison, consider alternatives such as Vector.LengthSqr .