Vector3::add
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
- Functions
- Properties
- Vector3::x
- Vector3::y
- Vector3::z