Vector3::subtract

From RAGE Multiplayer Wiki
Jump to navigation Jump to search

This function is used to subtract a Vector3 or scalar from another Vector3.

Syntax

vector.subtract(Vector3 otherVec);
vector.subtract(number scalar);

Required Arguments

  • otherVec: Vector3: The vector or scalar to be subtracted from the callee.

Returns

  • Vector3 The difference.

Example #1

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

const difference = vec1.subtract(vec2); // difference = {x: 40, y: 20, z: 15}

Example #2

Server-Side
const vec1 = new mp.Vector3(50, 40, 30);
const scalar = 30;

const difference = vec1.subtract(scalar); // difference = {x: 20, y: 10, z: 0}

See Also