{"name":"objectParent","title":"objectParent","type":"command","url":"https://community.bistudio.com/wiki/objectParent","revid":363381,"updated":"2024-03-29T13:23:37Z","groups":["Object Manipulation"],"status":"ok","games":{"arma3":"1.50"},"since":"arma3 1.50","arma3_since":"1.50","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","params":[{"name":"object","type":"Object","type_expr":"Object"}],"returns":{"type":"Object","type_expr":"Object"},"form":"unary","right":{"text":"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]);"]}],"see_also":["backpackContainer","unitBackpack","backpack","backpackCargo","getBackpackCargo","backpackItems","addBackpack","addBackpackCargo","addBackpackCargoGlobal","removeBackpack","clearBackpackCargo","clearBackpackCargoGlobal","clearAllItemsFromBackpack","loadBackpack","backpackSpaceFor","canAddItemToBackpack","addItemToBackpack","removeItemFromBackpack","everyBackpack","vehicle","getCorpse"]}