Garry's Mod Wiki


  Vector:Add( Vector vector )


Adds the values of the argument vector to the original vector. This function is the same as vector1 + vector2 without creating a new vector object, skipping object construction and garbage collection.


1 Vector vector
The vector to add.


Adds the components of the vectors together.

a = Vector(1, 1, 1) a:Add(Vector(1, 2, 3)) print(a)
Output: 2 3 4


If you don't want to set your vector to the result, and just return a new vector as the result. You can use a '+' operator to add two vectors together. The original vector will remain unchanged.

a = Vector(1, 1, 1) print(a + Vector(1, 2, 3))
Output: 2 3 4