{"name":"camSetDive","title":"camSetDive","type":"command","url":"https://community.bistudio.com/wiki/camSetDive","revid":352204,"updated":"2024-02-01T23:26:03Z","groups":["Broken Commands","Camera Control"],"status":"broken","games":{"ofp":"1.00","ofpe":"1.00","arma1":"1.00","arma2":"1.00","arma2oa":"1.50","tkoh":"1.00","arma3":"0.50"},"since":"ofp 1.00","arma3_since":"0.50","description":"Sets camera dive angle. Does not commit changes.\n\n> [!WARNING]\n> This command is **non-functional**!","syntaxes":[{"syntax":"camera camSetDive dive","params":[{"name":"camera","type":"Object","type_expr":"Object"},{"name":"dive","type":"Number","type_expr":"Number"}],"returns":{"type":"Nothing","type_expr":"Nothing"},"form":"binary","left":{"text":"camera"},"right":{"text":"dive"}}],"examples":[{"code":["_camera camSetDive -0.1;"]}],"see_also":["camSetBank","setVectorUp"],"notes":[{"user":"Kronzky","date":"2010-04-15T18:29:00Z","text":"Command is non-functional.\nInstead use setVectorUp or [this user function](http://forums.bistudio.com/showthread.php?t=67384) in Armed Assault.\n\n```sqf\n// Get Pitch and Bank\n// By General Barron (aw_barron@hotmail.com) and vektorboson\n// Parameters: object\n// Returns: [pitch, bank]\n// Returns the pitch and bank of an object, in degrees.\n// Yaw can be found using the getdir command.\n// Pitch is 0 when the object is level; 90 when pointing straight\n// up; and -90 when pointing straight down.\n// Bank is 0 when level; 90 when the object is rolled to the right,\n// -90 when rolled to the left, and 180 when rolled upside down.\n\n// extract parameters\nprivate [\"_obj\", \"_pitch\", \"_bank\", \"_yaw\", \"_vdir\", \"_vup\", \"_sign\", \"_rotate\"];\n_obj = _this;\n// find the yaw (direction) of the object\n// note that map compass directions go CW, while coordinate (vector) directions go CCW\n// so when we rotate vectors by this much (below), we are actually adjusting the vector as though the object were pointing north\n_yaw = getDir _obj;\n\n//----------------------------\n// function to rotate a 2d vector around the origin\n//----------------------------\n_rotate =\n{\n    private [\"_v\", \"_d\", \"_x\", \"_y\"];\n\n    // extract parameters\n    _v = +(_this select 0); // we don't want to modify the originally passed vector\n    _d = _this select 1;\n\n    // extract old x/y values\n    _x = _v select 0;\n    _y = _v select 1;\n    // if vector is 3d, we don't want to mess up the last element\n    _v set [0, (cos _d)*_x - (sin _d)*_y];\n    _v set [1, (sin _d)*_x + (cos _d)*_y];\n    // return new vector\n    _v;\n};\n//----------------------------\n// find pitch\n//----------------------------\n// get vector dir (pitch)\n_vdir = vectorDir _obj;\n\n// rotate X & Y around the origin according to the object's yaw (direction)\n// we will then be left with the objects vectordir if it were facing north\n_vdir = [_vdir, _yaw] call _rotate;\n\n// if we reverse the process we used to set pitch when facing north, we can now get pitch\nif ((_vdir select 1) != 0) then\n{\n    _pitch = atan ((_vdir select 2) / (_vdir select 1));\n}\nelse\n{\n    // we need a fail-safe here to prevent divide-by-zero errors\n    // if X is zero, that means pitch is +/-90, we just need to figure out which one\n    if ((_vdir select 2) >= 0) then { _pitch = 90 } else { _pitch = -90 };\n};\n\n//----------------------------\n// find bank\n//----------------------------\n// get vector up (bank)\n_vup = vectorUp _obj;\n\n// rotate X & Y around the origin according to the object's yaw (direction)\n// we will then be left with the objects vectorup if it were facing north\n_vup = [_vup, _yaw] call _rotate;\n\n// rotate Y & Z around according to the object's pitch\n_vup = [_vup select 0] + ([[_vup select 1, _vup select 2], 360 - _pitch] call _rotate);\n\n// if we reverse the process we used to set bank when facing north, we can now get bank\nif ((_vup select 2) != 0) then\n{\n    _bank = atan ((_vup select 0) / (_vup select 2));\n}\nelse\n{\n    // we need a fail-safe here to prevent divide-by-zero errors\n    // if Z is zero, that means bank is +/-90, we just need to figure out which one\n    if ((_vdir select 2) >= 0) then { _bank = 90 } else { _bank = -90 };\n};\n\n// if we are rolled over (abs bank > 90), we need to adjust our result\nif ((_vup select 2) < 0) then\n{\n    _sign = [1, -1] select (_bank < 0);\n    _bank = _bank - _sign*180;\n};\n\n//----------------------------\n// return value\n//----------------------------\n[_pitch, _bank];\n```"}]}