{"name":"vectorAdd","title":"vectorAdd","type":"command","url":"https://community.bistudio.com/wiki/vectorAdd","revid":378392,"updated":"2026-04-04T07:53:40Z","groups":["Math - Vectors"],"status":"ok","games":{"arma3":"1.22"},"since":"arma3 1.22","arma3_since":"1.22","description":"Adds two arrays of numbers. Replaces BIS_fnc_vectorAdd.\n\n> [!NOTE]\n> **Since Arma 3 v2.14:** Since Arma 3 v2.14 any count of numbers is valid, if one array is larger than the other, the remaining elements are inserted without change.\n> Before Arma 3 v2.14, the first argument had to be vector 3D, or Arma 3 v2.00 2D (Which still returned 3D result, with z coordinate defaulted to 0)","syntaxes":[{"syntax":"vector1 vectorAdd vector2","params":[{"name":"vector1","type":"Array of Numbers","description":"can be any size","type_expr":"Array<Number>"},{"name":"vector2","type":"Array of Numbers","description":"can be any size","type_expr":"Array<Number>"}],"returns":{"type":"Array of Numbers","type_expr":"Array<Number>"},"form":"binary","left":{"text":"vector1"},"right":{"text":"vector2"}}],"examples":[{"code":["hint str (velocity unit1 vectorAdd velocity unit2);"]},{"text":"```sqf\n[5, 10, 5] vectorAdd [5, 5, 10];            // returns [10, 15, 15]\n```","code":["[5, 10, 5] vectorAdd [5, 5, 10];\t\t\t// returns [10, 15, 15]"]},{"text":"```sqf\n[0, 0] vectorAdd [1, -2];                    // returns [1, -2]\n```","code":["[0, 0] vectorAdd [1, -2];\t\t\t\t\t// returns [1, -2]"]},{"text":"```sqf\n[1, 2, 3, 4, 5, 6] vectorAdd [10, 10, 10];    // returns [11, 12, 13, 4, 5, 6]\n```","code":["[1, 2, 3, 4, 5, 6] vectorAdd [10, 10, 10];\t// returns [11, 12, 13, 4, 5, 6]"]},{"text":"```sqf\n[1, 2, 3] vectorAdd [1, 2, 3];    // [2, 4, 6]\n[1, 2, 3] vectorAdd [1, 2];        // [2, 4, 3]\n[1, 2] vectorAdd [1, 2, 3];        // [2, 4, 3]\n[1, 2] vectorAdd [1, 2];        // [2, 4]\n```","code":["[1, 2, 3] vectorAdd [1, 2, 3];\t// [2, 4, 6]\n[1, 2, 3] vectorAdd [1, 2];\t\t// [2, 4, 3]\n[1, 2] vectorAdd [1, 2, 3];\t\t// [2, 4, 3]\n[1, 2] vectorAdd [1, 2];\t\t// [2, 4]"]}],"see_also":["vectorDiff","vectorCrossProduct","vectorDotProduct","vectorCos","vectorMagnitude","vectorMagnitudeSqr","vectorMultiply","vectorDistance","vectorDistanceSqr","vectorDir","vectorUp","setVectorDir","setVectorUp","setVectorDirAndUp","matrixMultiply","matrixTranspose"],"notes":[{"user":"Lou Montana","date":"2023-11-02T17:40:30Z","text":"```sqf\n// between File:Arma 3 logo black.png 2.00 and File:Arma 3 logo black.png 2.14:\n[1, 2] vectorAdd [1, 2]; // [2, 4, 0]\n```"}]}