{"name":"objectParent","operator":null,"title":"objectParent","type":"command","url":"https://community.bistudio.com/wiki/objectParent","revid":363381,"updated":"2024-03-29T13:23:37Z","groups":["Object Manipulation"],"status":"ok","replaced_by":[],"games":[{"game":"arma3","name":"Arma 3","version":"1.50"}],"since":{"game":"arma3","name":"Arma 3","version":"1.50"},"arma3_since":"1.50","branch":null,"locality":{"argument":null,"effect":null,"server_exec":false},"exec":null,"description":"Returns the parent of an object if said object is a proxy.\n\n> [!IMPORTANT]\n> Use objectParent instead of vehicle to get a soldier's vehicle.\n> Apart from being faster it is also more reliable, as when used on dead crew, vehicle command may surprisingly return the unit itself.\n\n> [!NOTE]\n> Since Arma 3 v2.18 objectParent can return the creator of a weaponholder if the weaponholder was created through some user action.","syntaxes":[{"syntax":"objectParent object","since":null,"effect":null,"exec":null,"params":[{"name":"object","type":"Object","optional":false,"default":null,"description":null,"types":["Object"],"since":null,"text":"object: Object"}],"returns":{"type":"Object","types":["Object"],"description":null,"text":"Object"},"form":"unary","operator":null,"left":null,"right":{"text":"object","types":["Object"]}}],"examples":[{"text":"```sqf\n_isOnFoot = isNull objectParent player;                            // check if the player is on foot\n_isCommander = player isEqualTo commander objectParent player;    // check if the player is in a vehicle and is its commander\n\n_holder = objectParent _myBackpack;                                // return:\n                                                                // - the weapon holder of a dropped backpack\n                                                                // - the cargo space of a vehicle holding this backpack\n                                                                // - the dead unit holding the backpack\n                                                                // works for a backpack, a vest or a uniform\n\n_isDeployed = isNull objectParent _deployableStaticMG;            // true if deployed, false if in a backpack\n\n_ropeParent = objectParent _ropeSegment;                        // since Arma 3 v2.12\n_creatorUnit = objectParent _weaponholder;                        // since Arma 3 v2.18\n```","code":["_isOnFoot = isNull objectParent player;\t\t\t\t\t\t\t// check if the player is on foot\n_isCommander = player isEqualTo commander objectParent player;\t// check if the player is in a vehicle and is its commander\n\n_holder = objectParent _myBackpack;\t\t\t\t\t\t\t\t// return:\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// - the weapon holder of a dropped backpack\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// - the cargo space of a vehicle holding this backpack\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// - the dead unit holding the backpack\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// works for a backpack, a vest or a uniform\n\n_isDeployed = isNull objectParent _deployableStaticMG;\t\t\t// true if deployed, false if in a backpack\n\n_ropeParent = objectParent _ropeSegment;\t\t\t\t\t\t// since Arma 3 v2.12\n_creatorUnit = objectParent _weaponholder;\t\t\t\t\t\t// since Arma 3 v2.18"]},{"text":"Create and place a created backpack in front of player:\n\n```sqf\n_backpackContainer = \"B_TacticalPack_rgr\" createVehicle [0, 0, 0];\n_weaponHolder = objectParent _backpackContainer;\n_weaponHolder setPosWorld (player modelToWorldWorld [0, 5, 0]);\n```","code":["_backpackContainer = \"B_TacticalPack_rgr\" createVehicle [0, 0, 0];\n_weaponHolder = objectParent _backpackContainer;\n_weaponHolder setPosWorld (player modelToWorldWorld [0, 5, 0]);"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["backpackContainer","unitBackpack","backpack","backpackCargo","getBackpackCargo","backpackItems","addBackpack","addBackpackCargo","addBackpackCargoGlobal","removeBackpack","clearBackpackCargo","clearBackpackCargoGlobal","clearAllItemsFromBackpack","loadBackpack","backpackSpaceFor","canAddItemToBackpack","addItemToBackpack","removeItemFromBackpack","everyBackpack","vehicle","getCorpse"],"notes":[],"categories":["Arma 3: New Scripting Commands","Arma 3: Scripting Commands","Command Group: Object Manipulation","Introduced with Arma 3 version 1.50","Scripting Commands"]}