Vector3::add

From RAGE Multiplayer Wiki
Revision as of 05:45, 31 May 2019 by Micaww (talk | contribs) (Created page with "This function is used to add a Vector3 to another Vector3. ==Syntax== <pre> vector.add(Vector3 otherVec); </pre> ===Required Arguments=== *'''otherVec:''' Vector3: The vecto...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This function is used to add a Vector3 to another Vector3.

Syntax

vector.add(Vector3 otherVec);

Required Arguments

  • otherVec: Vector3: The vector to be added to the callee.

Example #1

Server-Side
const vec1 = new mp.Vector3(10, 30, 100);
const vec2 = new mp.Vector3(40, 20, 60);

const total = vec1.add(vec2); // total = {x: 50, y: 50, z: 160}

Example #2

This will throw all players 500 units into the air.

Server-Side
mp.players.forEach(player => {
    player.position = player.position.add(new mp.Vector3(0, 0, 500));
});

See Also