{"name":"setVectorDir","operator":null,"title":"setVectorDir","type":"command","url":"https://community.bistudio.com/wiki/setVectorDir","revid":377248,"updated":"2026-01-02T05:42:47Z","groups":["Math - Vectors"],"status":"ok","replaced_by":[],"games":[{"game":"ofpe","name":"Operation Flashpoint: Elite","version":"1.00"},{"game":"arma1","name":"Armed Assault","version":"1.00"},{"game":"arma2","name":"Arma 2","version":"1.00"},{"game":"arma2oa","name":"Arma 2: Operation Arrowhead","version":"1.50"},{"game":"tkoh","name":"Take On Helicopters","version":"1.00"},{"game":"arma3","name":"Arma 3","version":"0.50"}],"since":{"game":"ofpe","name":"Operation Flashpoint: Elite","version":"1.00"},"arma3_since":"0.50","branch":null,"locality":{"argument":"local","effect":"global","server_exec":false},"exec":null,"description":"Set object's direction vector. Up vector will remain unchanged.","syntaxes":[{"syntax":"object setVectorDir vectorDir","since":null,"effect":null,"exec":null,"params":[{"name":"object","type":"Object","optional":false,"default":null,"description":null,"types":["Object"],"since":null,"text":"object: Object"},{"name":"vectorDir","type":"Vector3D","optional":false,"default":null,"description":null,"types":["Vector3D"],"since":null,"text":"vectorDir: Vector3D"}],"returns":{"type":"Nothing","types":["Nothing"],"description":null,"text":"Nothing"},"form":"binary","operator":null,"left":{"text":"object","types":["Object"]},"right":{"text":"vectorDir","types":["Vector3D"]}}],"examples":[{"text":"```sqf\nplayer setVectorDir [5,6,1];\n```","code":["player setVectorDir [5,6,1];"]},{"text":"```sqf\n// provided _myMine is local\n_myMine setVectorDir [0.3, 1, 0];\n_myMine setPosWorld getPosWorld _myMine; // synchronises the mine's direction over the network (special case)\n```","code":["// provided _myMine is local\n_myMine setVectorDir [0.3, 1, 0];\n_myMine setPosWorld getPosWorld _myMine; // synchronises the mine's direction over the network (special case)"]}],"multiplayer":null,"problems":"The effect is Local Effect when using setVectorDir on a mine. Use a position modification to broadcast setVectorDir's change (see #Example 2).","aliases":[],"see_also":["vectorDir","vectorUp","setVectorUp","setVectorDirAndUp","vectorDiff","vectorAdd","vectorMultiply","vectorCrossProduct","vectorDistance","vectorMagnitudeSqr","vectorDistanceSqr","vectorCos","vectorMagnitude","vectorDotProduct","vectorNormalized","vectorFromTo"],"notes":[{"user":"Str","date":"2008-03-16T09:50:00Z","text":"Command can be also used to rotate camera in all three axis."},{"user":"General Barron","date":"2009-03-03T21:06:00Z","text":"setVectorDir can only influence an object's pitch. It can not influence bank. Example:\n\n```sqf\nplayer setVectorDir [0,0,1];\n```\n\n- If the player is facing 0 degrees (north), then this will do NOTHING.\n- If the player is facing 90 degrees (east), then this will make him pitch 90 degrees up.\nYou can't directly pitch an object beyond 90 degrees, because this would change its facing direction. You must first flip it is direction using setDir, then you must bank the object 180 degrees, THEN you pitch the object appropriately."},{"user":"DreadedEntity","date":"2015-08-17T03:27:00Z","text":"In Arma 3, setVectorDir does not control an object's pitch or bank, in fact, it is not possible to change either of those solely using setVectorDir. This command can only affect horizontal rotation along the x-plane, unless an object first has it is vectorUp changed to something other than [0,0,1]. Correct input to setVectorDir should be calculated using the trigonometric functions sin and cos.\n\nexamples:\n\n```sqf\n// 0 degrees (north)\nplayer setVectorDir\n[\n    sin 0, // equals 0\n    cos 0, // equals 1\n    1\n];\n// 45 degrees (north-east)\nplayer setVectorDir\n[\n    sin 45, // equals 0.707\n    cos 45, // equals 0.707\n    1\n];\n```\n\nIf you are doing trigonometric calculations, it may be better to use setVectorDir rather than setDir, since sine and cosine have already been calculated and will not need to be re-calculated\n(also, setDir probably uses setVectorDir anyway.)"}],"categories":["ArmA: Armed Assault: Scripting Commands","Arma 2: Operation Arrowhead: Scripting Commands","Arma 2: Scripting Commands","Arma 3: Scripting Commands","Command Group: Math - Vectors","Introduced with Operation Flashpoint: Elite version 1.00","Operation Flashpoint: Elite: New Scripting Commands","Operation Flashpoint: Elite: Scripting Commands","Scripting Commands","Scripting Commands: Global Effect","Take On Helicopters: Scripting Commands"]}