{"name":"camSetDive","operator":null,"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","replaced_by":[],"games":[{"game":"ofp","name":"Operation Flashpoint","version":"1.00"},{"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":"ofp","name":"Operation Flashpoint","version":"1.00"},"arma3_since":"0.50","branch":null,"locality":{"argument":null,"effect":null,"server_exec":false},"exec":null,"description":"Sets camera dive angle. Does not commit changes.\n\n> [!WARNING]\n> This command is **non-functional**!","syntaxes":[{"syntax":"camera camSetDive dive","since":null,"effect":null,"exec":null,"params":[{"name":"camera","type":"Object","optional":false,"default":null,"description":null,"types":["Object"],"since":null,"text":"camera: Object"},{"name":"dive","type":"Number","optional":false,"default":null,"description":null,"types":["Number"],"since":null,"text":"dive: Number"}],"returns":{"type":"Nothing","types":["Nothing"],"description":null,"text":"Nothing"},"form":"binary","operator":null,"left":{"text":"camera","types":["Object"]},"right":{"text":"dive","types":["Number"]}}],"examples":[{"text":"```sqf\n_camera camSetDive -0.1;\n```","code":["_camera camSetDive -0.1;"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["camSetBank","setVectorUp"],"notes":[{"user":"Kronzky","date":"2010-04-15T18:29:00Z","text":"Command is non-functional.\n\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```"}],"categories":["ArmA: Armed Assault: Scripting Commands","Arma 2: Operation Arrowhead: Scripting Commands","Arma 2: Scripting Commands","Arma 3: Scripting Commands","Command Group: Broken Commands","Command Group: Camera Control","Introduced with Operation Flashpoint version 1.00","Operation Flashpoint: Elite: Scripting Commands","Operation Flashpoint: New Scripting Commands","Operation Flashpoint: Scripting Commands","Scripting Commands","Take On Helicopters: Scripting Commands"]}