Garry's Mod Wiki

Vector:Add

  Vector:Add( Vector vector )

Description

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.

Arguments

1 Vector vector
The vector to add.

Example

Adds the components of the vectors together.

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

Example

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