{"name":"BIS_fnc_dirTo","operator":null,"title":"BIS fnc dirTo","type":"function","url":"https://community.bistudio.com/wiki/BIS_fnc_dirTo","revid":327975,"updated":"2022-07-13T14:37:05Z","groups":["Geometry"],"status":"ok","replaced_by":[],"games":[{"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":"arma2","name":"Arma 2","version":"1.00"},"arma3_since":"0.50","branch":null,"locality":{"argument":null,"effect":null,"server_exec":false},"exec":null,"description":"Function which returns vector direction from pos1 to pos2.\n\n> [!NOTE]\n> **Arma 3:** Use `obj1 getDir obj2` instead of BIS_fnc_dirTo.","syntaxes":[{"syntax":"[param1, param2] call BIS_fnc_dirTo","since":null,"effect":null,"exec":null,"params":[{"name":"param1","type":null,"optional":false,"default":null,"description":"vector starting point, Position **or** Object","types":[],"since":null,"text":"param1 - vector starting point, Position **or** Object"},{"name":"param2","type":null,"optional":false,"default":null,"description":"vector ending point, Position **or** Object","types":[],"since":null,"text":"param2 - vector ending point, Position **or** Object"}],"returns":{"type":"Number","types":["Number"],"description":null,"text":"Number"}}],"examples":[{"text":"sets unit1 in the direction of unit2\n\n```sqf\nunit1 setDir ([unit1, unit2] call BIS_fnc_dirTo);\n```","code":["unit1 setDir ([unit1, unit2] call BIS_fnc_dirTo);"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["getDir","setDir"],"notes":[{"user":"AgentRev","date":"2015-01-21T14:20:00Z","text":"Be careful when using this function in conjunction with BIS_fnc_rotateVector2D, which rotates vectors counterclockwise as per trigonometric conventions, while BIS_fnc_dirTo returns a clockwise angle.\n\nTo counter this, simply negate the output of BIS_fnc_dirTo:\n\n```sqf\n[0,1,0], -([_unit, _vehicle] call BIS_fnc_dirTo)] call BIS_fnc_rotateVector2D;\n```"}],"categories":["Arma 2: Functions","Arma 2: New Functions","Arma 2: Operation Arrowhead: Functions","Arma 3: Functions","Function Group: Geometry","Functions","Introduced with Arma 2 version 1.00","Take On Helicopters: Functions"],"docblock":null,"filled_from_docblock":[]}