{"name":"BIS_fnc_setPitchBank","operator":null,"title":"BIS fnc setPitchBank","type":"function","url":"https://community.bistudio.com/wiki/BIS_fnc_setPitchBank","revid":328367,"updated":"2022-07-13T16:00:47Z","groups":["Object Manipulation"],"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":"Rotate an object, giving it the specified pitch and bank, in degrees.\n\n**Pitch** is 0 when the object is level; 90 when pointing straight up; and -90 when pointing straight down.\n\n**Bank** is 0 when level; 90 when the object is rolled to the right, -90 when rolled to the left, and 180 when rolled upside down.\n\nNote that the object's **yaw** can be set with the setDir command, which should be issued before using this function, if required.\n\nThe pitch/bank can be leveled out (set to 0) by using the setDir command.","syntaxes":[{"syntax":"[object, pitch, bank] call BIS_fnc_setPitchBank","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":"pitch","type":"Number","optional":false,"default":null,"description":null,"types":["Number"],"since":null,"text":"pitch: Number"},{"name":"bank","type":"Number","optional":false,"default":null,"description":null,"types":["Number"],"since":null,"text":"bank: Number"}],"returns":{"type":"Nothing","types":["Nothing"],"description":null,"text":"Nothing"}}],"examples":[{"text":"```sqf\n[player, 45, -45] call BIS_fnc_setPitchBank;\n```","code":["[player, 45, -45] call BIS_fnc_setPitchBank;"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["BIS_fnc_getPitchBank","vectorDir","vectorUp","setVectorDirAndUp"],"notes":[{"user":"ffur2007slx2_5","date":"2014-08-04T13:35:00Z","text":"> [!NOTE]\n> See also BIS_fnc_setObjectRotation.\n\n(A3 1.24) attachTo limits BIS_fnc_setPitchBank, here’s an alternative function to break that limitation (code originated from bapedibupa):\n\n```sqf\n_obj attachTo [_logic,[0,0,2]];\n[_obj,[120,-78,37]] call fnc_SetPitchBankYaw; // pitch: 120, bank: -78, yaw: 37\n```\n\n```sqf\nfnc_SetPitchBankYaw = { \n    private [\"_object\",\"_rotations\",\"_aroundX\",\"_aroundY\",\"_aroundZ\",\"_dirX\",\"_dirY\",\"_dirZ\",\"_upX\",\"_upY\",\"_upZ\",\"_dir\",\"_up\",\"_dirXTemp\",\n    \"_upXTemp\"];\n    _object = _this select 0;\n    _rotations = _this select 1;\n    _aroundX = _rotations select 0;\n    _aroundY = _rotations select 1;\n    _aroundZ = (360 - (_rotations select 2)) - 360;\n    _dirX = 0;\n    _dirY = 1;\n    _dirZ = 0;\n    _upX = 0;\n    _upY = 0;\n    _upZ = 1;\n    if (_aroundX != 0) then { \n        _dirY = cos _aroundX;\n        _dirZ = sin _aroundX;\n        _upY = -sin _aroundX;\n        _upZ = cos _aroundX;\n    };\n    if (_aroundY != 0) then { \n        _dirX = _dirZ * sin _aroundY;\n        _dirZ = _dirZ * cos _aroundY;\n        _upX = _upZ * sin _aroundY;\n        _upZ = _upZ * cos _aroundY;\n    };\n    if (_aroundZ != 0) then { \n        _dirXTemp = _dirX;\n        _dirX = (_dirXTemp* cos _aroundZ) - (_dirY * sin _aroundZ);\n        _dirY = (_dirY * cos _aroundZ) + (_dirXTemp * sin _aroundZ);\n        _upXTemp = _upX;\n        _upX = (_upXTemp * cos _aroundZ) - (_upY * sin _aroundZ);\n        _upY = (_upY * cos _aroundZ) + (_upXTemp * sin _aroundZ);\n    };\n    _dir = [_dirX,_dirY,_dirZ];\n    _up = [_upX,_upY,_upZ];\n    _object setVectorDirAndUp [_dir,_up];\n};\n```"}],"categories":["Arma 2: Functions","Arma 2: New Functions","Arma 2: Operation Arrowhead: Functions","Arma 3: Functions","Function Group: Object Manipulation","Functions","Introduced with Arma 2 version 1.00","Take On Helicopters: Functions"],"docblock":null,"filled_from_docblock":[]}