{"name":"vectorDiff","operator":null,"title":"vectorDiff","type":"command","url":"https://community.bistudio.com/wiki/vectorDiff","revid":377116,"updated":"2026-01-01T10:12:56Z","groups":["Math - Vectors"],"status":"ok","replaced_by":[],"games":[{"game":"arma3","name":"Arma 3","version":"1.22"}],"since":{"game":"arma3","name":"Arma 3","version":"1.22"},"arma3_since":"1.22","branch":null,"locality":{"argument":null,"effect":null,"server_exec":false},"exec":null,"description":"Subtracts one 3D vector from another. (vector1 - vector2)\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>\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 vectorDiff vector2","since":null,"effect":null,"exec":null,"params":[{"name":"vector1","type":"Array of Numbers","optional":false,"default":null,"description":null,"types":["Array","Number"],"since":null,"text":"vector1: Array of Numbers"},{"name":"vector2","type":"Array of Numbers","optional":false,"default":null,"description":null,"types":["Array","Number"],"since":null,"text":"vector2: Array of Numbers"}],"returns":{"type":"Array of Numbers","types":["Array","Number"],"description":null,"text":"Array of Numbers"},"form":"binary","operator":null,"left":{"text":"vector1","types":["Array","Number"]},"right":{"text":"vector2","types":["Array","Number"]}}],"examples":[{"text":"```sqf\nhint str (velocity car vectorDiff velocity bike);\n```","code":["hint str (velocity car vectorDiff velocity bike);"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["vectorAdd","vectorCrossProduct","vectorDotProduct","vectorCos","vectorMagnitude","vectorMagnitudeSqr","vectorMultiply","vectorDistance","vectorDistanceSqr","vectorDir","vectorUp","setVectorDir","setVectorUp","setVectorDirAndUp","vectorNormalized","vectorFromTo"],"notes":[{"user":"ffur2007slx2_5","date":"2014-06-28T09:09:00Z","text":"Arma 3 v1.22 Algorithm:\n\n```sqf\nVector1 = [x1,y1,z1]; Vector2 = [x2,y2,z2];\nResult = [x1 - x2, y1 - y2, z1 - z2];\n```\n\nIt is recommended to use vectorDiff instead of BIS_fnc_vectorDiff."}],"categories":["Arma 3: New Scripting Commands","Arma 3: Scripting Commands","Command Group: Math - Vectors","Introduced with Arma 3 version 1.22","Scripting Commands"]}