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

Difference between revisions of "vlen"

From Quake Wiki

 
Line 1: Line 1:
====Syntax:====
+
''float'' '''vlen'''(''vector'' vec)
<code>float vlen(vector vec)</code>
 
  
Gets the absolute length of a vector
+
== Usage ==
====Parameters:====
+
Gets the length of the vector. This is always a positive value.
:<code>vec</code> - The vector to measure
 
====Returns:====
 
:Returns the absolute length of the vector.
 
  
 +
=== Parameters ===
 +
*''vec''
 +
:The vector to get the length of.
 +
 +
=== Return ===
 +
The length of the passed vector.
 +
 +
== Example ==
 +
// Check to make sure a monster's enemy is in range for an attack
 +
float distance = vlen(self.enemy.origin - self.origin);
 +
if (distance > 512)
 +
    return;
  
 
[[Category:QuakeC Function]]
 
[[Category:QuakeC Function]]

Latest revision as of 12:17, 31 July 2023

float vlen(vector vec)

Usage[edit]

Gets the length of the vector. This is always a positive value.

Parameters[edit]

  • vec
The vector to get the length of.

Return[edit]

The length of the passed vector.

Example[edit]

// Check to make sure a monster's enemy is in range for an attack
float distance = vlen(self.enemy.origin - self.origin);
if (distance > 512)
    return;