{"name":"setObjectScale","operator":null,"title":"setObjectScale","type":"command","url":"https://community.bistudio.com/wiki/setObjectScale","revid":364325,"updated":"2024-05-06T09:38:47Z","groups":["Object Manipulation"],"status":"ok","replaced_by":[],"games":[{"game":"arma3","name":"Arma 3","version":"2.02"}],"since":{"game":"arma3","name":"Arma 3","version":"2.02"},"arma3_since":"2.02","branch":null,"locality":{"argument":"local","effect":"global","server_exec":false},"exec":null,"description":"Scales an attached object or a Simple Object's model - see #Example 3 for various configurations' examples.","syntaxes":[{"syntax":"object setObjectScale scale","since":null,"effect":null,"exec":null,"params":[{"name":"object","type":"Object","optional":false,"default":null,"description":"must be either an attached object or Simple Object - see #Example 3","types":["Object"],"since":null,"text":"object: Object - must be either an attached object or Simple Object - see #Example 3"},{"name":"scale","type":"Number","optional":false,"default":null,"description":"in range 0.0001..65504, relative to the object model's normal scale","types":["Number"],"since":null,"text":"scale: Number - in range 0.0001..65504, relative to the object model's normal scale"}],"returns":{"type":"Nothing","types":["Nothing"],"description":null,"text":"Nothing"},"form":"binary","operator":null,"left":{"text":"object","types":["Object"]},"right":{"text":"scale","types":["Number"]}}],"examples":[{"text":"```sqf\n_vehicle attachTo [player, [0,0,0]];\n_vehicle setObjectScale 0.1;\n```","code":["_vehicle attachTo [player, [0,0,0]];\n_vehicle setObjectScale 0.1;"]},{"text":"```sqf\n// select an object in Eden Editor and execute the following code in the Debug Console. When moving the object, the effect is reset!\nprivate _object = get3DENSelected \"Object\" select 0;\n_object setObjectScale 0.1;\n```","code":["// select an object in Eden Editor and execute the following code in the Debug Console. When moving the object, the effect is reset!\nprivate _object = get3DENSelected \"Object\" select 0;\n_object setObjectScale 0.1;"]},{"text":"```sqf\n// multiple MP-compatible options\n\n// global simple object\nprivate _globalSimpleObject = createSimpleObject [\"C_Offroad_01_F\", getPosASL player, false];\n_globalSimpleObject setObjectScale 0.1; // once is enough as long as it is not moved\n\n// local normal object\nprivate _localNormalObject = \"C_Offroad_01_F\" createVehicleLocal getPosATL player;\n_localNormalObject attachTo [player, [0, 2, 1.5]]; // normal object must be attached\n_localNormalObject setObjectScale 0.1; // once is enough as long as it is not moved\n\n// local simple object\nprivate _localSimpleObject = createSimpleObject [\"C_Offroad_01_F\", getPosASL player, true];\n_localSimpleObject setObjectScale 0.1; // once is enough as long as it is not moved\n```","code":["// multiple MP-compatible options\n\n// global simple object\nprivate _globalSimpleObject = createSimpleObject [\"C_Offroad_01_F\", getPosASL player, false];\n_globalSimpleObject setObjectScale 0.1; // once is enough as long as it is not moved\n\n// local normal object\nprivate _localNormalObject = \"C_Offroad_01_F\" createVehicleLocal getPosATL player;\n_localNormalObject attachTo [player, [0, 2, 1.5]]; // normal object must be attached\n_localNormalObject setObjectScale 0.1; // once is enough as long as it is not moved\n\n// local simple object\nprivate _localSimpleObject = createSimpleObject [\"C_Offroad_01_F\", getPosASL player, true];\n_localSimpleObject setObjectScale 0.1; // once is enough as long as it is not moved"]},{"text":"```sqf\n// a not-so-great EachFrame workaround for a non-attached object\n\n// a normal object that is not attached must be scaled each frame\n// make sure the object is LOCAL in order to not saturate the network!\nprivate _localNormalObject = \"C_Offroad_01_F\" createVehicleLocal getPosATL player;\n// the object is not attached to anything\naddMissionEventHandler [\n    \"EachFrame\",\n    { _thisArgs params [\"_obj\", \"_scale\"]; _obj setObjectScale _scale; },\n    [_localNormalObject, 0.1]\n];\n```","code":["// a not-so-great EachFrame workaround for a non-attached object\n\n// a normal object that is not attached must be scaled each frame\n// make sure the object is LOCAL in order to not saturate the network!\nprivate _localNormalObject = \"C_Offroad_01_F\" createVehicleLocal getPosATL player;\n// the object is not attached to anything\naddMissionEventHandler [\n\t\"EachFrame\",\n\t{ _thisArgs params [\"_obj\", \"_scale\"]; _obj setObjectScale _scale; },\n\t[_localNormalObject, 0.1]\n];"]},{"text":"```sqf\n// only do the following in single player;\n// NEVER do such EachFrame in multiplayer!!\n// the performance will be terrible, the network will be saturated, the scaling may desync and not be perfect\nprivate _globalNormalObject = \"C_Offroad_01_F\" createVehicle getPosATL player;\naddMissionEventHandler [\n    \"EachFrame\",\n    { _thisArgs params [\"_obj\", \"_scale\"]; _obj setObjectScale _scale; },\n    [_globalNormalObject, 0.1]\n];\n```","code":["// only do the following in single player;\n// NEVER do such EachFrame in multiplayer!!\n// the performance will be terrible, the network will be saturated, the scaling may desync and not be perfect\nprivate _globalNormalObject = \"C_Offroad_01_F\" createVehicle getPosATL player;\naddMissionEventHandler [\n\t\"EachFrame\",\n\t{ _thisArgs params [\"_obj\", \"_scale\"]; _obj setObjectScale _scale; },\n\t[_globalNormalObject, 0.1]\n];"]}],"multiplayer":null,"problems":"The Arma 3 LOD limits still apply, meaning walkable surfaces can only be (~70?)m in size, and collision in general will only work up to (?)m from object center.\nThis command works on all objects in Eden Editor or scenario preview, but it will not save and will reset when objects get moved. Eden Editor support is only intended for artists.\n\n> [!NOTE]\n> Setting the scale of non-simple objects, such as vehicles with players/AI in them, static objects (`simulation = \"house\"` in config), etc. might be possible,\n> but not officially supported. You may encounter issues.\n\n> [!IMPORTANT]\n> Changing the direction of the object (e.g. using setDir, setVectorDir, etc.) will reset the object back to its original size (probably because the engine normalises the directions,\n> thus the scale in the transformation matrix becomes 1), so those commands should be run **before** resizing the object.","aliases":[],"see_also":["getObjectScale","createVehicleLocal","createSimpleObject","BIS_fnc_createSimpleObject","Multiplayer Scripting"],"notes":[{"user":"P1ker1","date":"2022-01-04T22:17:33Z","text":"Note that\n\n```sqf\n_obj setObjectScale 2;\n```\n\ndoubles the scale factor of an object, not the volume. In the case of a cube this would be the length of an edge.\nIf you want to multiply the volume, raise the *scale* to the power of 1/3.\n\n```sqf\n// Example with 1x1x1 m^3 helper objects\n// vectorAdds elevate the cubes so they touch the ground after scaling.\n_cube1 = createSimpleObject [\"Land_VR_Shape_01_cube_1m_F\", getPosASL player vectorAdd [1,3,0.5]];\n_cube2 = createSimpleObject [\"Land_VR_Shape_01_cube_1m_F\", getPosASL player vectorAdd [3,1,0.5]];\n_cube3 = createSimpleObject [\"Land_VR_Shape_01_cube_1m_F\", getPosASL player vectorAdd [1.35,1.35,0.13]];\n\n// Double the side length. V=2^3=8\n_cube1 setObjectScale 2;\n\n// Octuple(8x) the volume.    V=(8^(1/3))^3=8\n_cube2 setObjectScale 8^(1/3);\n\n// Double the volume.        V=(2^(1/3))^3=2\n_cube3 setObjectScale 2^(1/3);\n```"}],"categories":["Arma 3: New Scripting Commands","Arma 3: Scripting Commands","Command Group: Object Manipulation","Introduced with Arma 3 version 2.02","Scripting Commands","Scripting Commands: Global Effect"]}