Vector/Add

From Garry's Mod
Jump to: navigation, search
 Vector:Add( )

Contents

Description

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

Arguments

Vector vector

The vector to add.

Examples

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

Examples

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
Personal tools
Navigation