createSimpleObject: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (minor link change)
m (Some wiki formatting)
 
(71 intermediate revisions by 8 users not shown)
Line 1: Line 1:
{{Command|= Comments
{{RV|type=command
|arma3|= Game name
|1.58|= Game version
|eff= global|= Effects in MP


| Create object with given shape defined as path to .p3d model. Supported [[LOD]]s include [[LOD#Geometry|Geometry]], [[LOD#Fire_Geometry|Fire Geometry]], [[LOD#Roadway|Roadway]], [[LOD#ViewGeometry|View Geometry]] and [[LOD#ShadowVolume|ShadowVolume]]. Supported features include collision, texturing, animation, penetration, AI spotting occlusion, and surface specific sounds (like footsteps). Unsupported features include PhysX, damage, AI pathfinding (causes walking through walls), and built in lights.<br><br>
|game1= arma3
|version1= 1.58


Given the simulation limitations, global decorative objects can be created with very little network traffic. Objects that could be exclusively created with this command are: trees, bushes, rocks, bridges, roads, vehicle wrecks, custom models in mission, and other objects without a class in config. The height of the placement position might need to be adjusted experimentally. Some of the model examples could be found here: [[createSimpleObject/objects]]<br><br>
|eff= global


Guide: [[Arma 3 Simple Objects]]<br><br>
|gr1= Object Manipulation


{{note|One '''cannot''' attach actions to a simple object via [[addAction]].}}
|descr= Create object with given shape defined as path to .p3d model. Supported [[LOD]]s include [[LOD#Geometry|Geometry]], [[LOD#Fire_Geometry|Fire Geometry]], [[LOD#Roadway|Roadway]], [[LOD#ViewGeometry|View Geometry]] and [[LOD#ShadowVolume|ShadowVolume]]. Supported features include collision, texturing, animation, penetration, AI spotting occlusion, and surface specific sounds (like footsteps). Unsupported features include PhysX, damage, AI pathfinding (causes walking through walls), and built-in lights.<br><br>


'''NOTES''':
Given the simulation limitations, global decorative objects can be created with very little network traffic. Objects that could be exclusively created with this command are: trees, bushes, rocks, bridges, roads, vehicle wrecks, custom models in mission, and other objects without a class in config. The height of the placement position might need to be adjusted experimentally.<br>
* Objects created with Syntax 1 cannot be textured. Some objects may also have inverted default direction.  
{{Feature|informative|
* Objects created with Syntax 2 can be textured. The default direction should match the direction of the object if it was created with [[createVehicle]].
* See [[Arma 3: Simple Objects]] to learn more about simple objects.
* See [[Arma 3: createSimpleObject/objects]] for a p3d models' list.
* See [[Arma 3: Livonia Props]] for [[Livonia]] furniture.


Since Arma 3 v1.67 simple objects support [[setVariable]] and [[getVariable]]
|= Description


| '''createSimpleObject''' [shapeName, positionWorld] |= Syntax
Please note that:
|p1= [shapeName, positionWorld]: [[Array]]|=
* [[addAction]] does not work with simple objects.
|p2= shapeName: [[String]] - Path to the 3d model (can be obtained with [[getModelInfo]] command) |= Parameter 1
* objects created with {{Link|#Syntax 1}} cannot be textured. Some objects may also have inverted default direction.
|p3= positionWorld: [[Array]] - placement position in format [[PositionWorld]] |= Parameter 2
* objects created with {{Link|#Syntax 2}} can be textured. The default direction should match the direction of the object if it was created with [[createVehicle]].
| [[Object]] - Created simple object |= RETURNVALUE
* only as of {{GVI|arma3|1.68}} do simple objects support [[getVariable]] and [[setVariable]].
}}
 
|s1= [[createSimpleObject]] [shapeName, positionWorld, local]
 
|p1= shapeName: [[String]] - path to the 3d model (can be obtained with [[getModelInfo]] command)
 
|p2= positionWorld: [[Array]] format [[Position#PositionASL|PositionASL]] - placement position by the '''model centre'''<nowiki/>'s position (see [[getPosWorld]])
 
|p3= local: [[Boolean]] - (Optional, default [[false]]) [[true]] to create a local instance only
|p3since= arma3 1.96
 
|r1= [[Object]] - created simple object
 
|s2= [[createSimpleObject]] [className, positionASL, local]
 
|p21= className: [[String]] - [[CfgVehicles]] class name
 
|p22= positionASL: [[Array]] format [[Position#PositionASL|PositionASL]] - placement position
 
|p23= local: [[Boolean]] - (Optional, default [[false]]) [[true]] to create a local instance only
|p23since= arma3 1.96


|s2= '''createSimpleObject''' [className, positionASL] |= Syntax
|r2= [[Object]] - created simple object
|p21= [className, positionASL] : [[Array]]|=
|p22= className: [[String]] - [[CfgVehicles]] config class name|= Parameter 1
|p23= positionASL: [[Array]] - placement position in format [[PositionASL]] |= Parameter 2
|r2= [[Object]] - Created simple object |= RETURNVALUE


|x1= <code>_pos = [[player]] [[getRelPos]] [10, 0];
|x1= <sqf>
_tank = [[createSimpleObject]] ["a3\armor_f_beta\apc_tracked_01\apc_tracked_01_rcws_f.p3d", _pos];
private _pos = player getRelPos [10, 0];
_tank [[setPos]] (_pos [[vectorAdd]] ([[getPosWorld]] _tank [[vectorDiff]] (_tank [[modelToWorld]] [0,0,0])));
private _tank = createSimpleObject ["a3\armor_f_beta\apc_tracked_01\apc_tracked_01_rcws_f.p3d", _pos];
_tank setPos (_pos vectorAdd (getPosWorld _tank vectorDiff (_tank modelToWorld [0,0,0])));


_tank [[hideSelection]] ["zasleh", [[true]]];
_tank hideSelection ["zasleh", true];
_tank [[hideSelection]] ["zasleh2", [[true]]];
_tank hideSelection ["zasleh2", true];
_tank [[hideSelection]] ["clan", [[true]]];
_tank hideSelection ["clan", true];
   
   
_tank [[animate]] ["Wheel_podkoloL3", 0.5, [[true]]];
_tank animate ["Wheel_podkoloL3", 0.5, true];
_tank [[animate]] ["Wheel_podkoloL6", 0.5, [[true]]];</code>|= EXAMPLE1
_tank animate ["Wheel_podkoloL6", 0.5, true];
</sqf>


|x2= <code>_pos = [[player]] [[getRelPos]] [10, 0];  
|x2= <sqf>
_tank = [[createSimpleObject]] ["B_APC_Tracked_01_CRV_F", [[AGLtoASL]] _pos];  
private _pos = player getRelPos [10, 0];
_tank [[setObjectTexture]] [0, "#(rgb,8,8,3)color(0,1,0,0.01)"];  
private _tank = createSimpleObject ["B_APC_Tracked_01_CRV_F", AGLToASL _pos];
_tank setObjectTexture [0, "#(rgb,8,8,3)color(0,1,0,0.01)"];


_tank [[hideSelection]] ["zasleh", [[true]]];  
_tank hideSelection ["zasleh", true];
_tank [[hideSelection]] ["zasleh2", [[true]]];  
_tank hideSelection ["zasleh2", true];
_tank [[hideSelection]] ["clan", [[true]]];  
_tank hideSelection ["clan", true];
    
    
_tank [[animate]] ["Wheel_podkoloL3", 0.5, [[true]]];  
_tank animate ["Wheel_podkoloL3", 0.5, true];
_tank [[animate]] ["Wheel_podkoloL6", 0.5, [[true]]];</code>|= EXAMPLE2
_tank animate ["Wheel_podkoloL6", 0.5, true];
</sqf>
 
|x3= Create a pond:
<sqf>
private _waterTileModel = "a3\structures_f_enoch\Water\pond_big_01.p3d"; // visual only - this pond is a hard surface
private _tileSize = 18; // width & height
private _tileX = 10;
private _tileY = 5;
private _bottomLeftCorner = getPosWorld player;
private _tilePos = -1;
private _tiles = [];
private _tile = objNull;
for "_y" from 0 to (_tileY - 1) do
{
for "_x" from 0 to (_tileX - 1) do
{
_tilePos = _bottomLeftCorner vectorAdd [_x * _tileSize, _y * _tileSize, 0];
_tile = createSimpleObject [_waterTileModel, _tilePos];
_tiles pushBack _tile;
};
};
sleep 10;
{ deleteVehicle _x } forEach _tiles;
</sqf>


| [[isSimpleObject]], [[hideSelection]], [[selectionPosition]], [[getModelInfo]], [[getObjectType]], [[cursorObject]], [[selectionNames]], [[animationNames]], [[createVehicle]], [[enableSimulation]], [[hideObject]], [[Arma_3_Simple_Objects|Simple Objects Guide]] |= SEEALSO
|seealso= [[isSimpleObject]] [[hideSelection]] [[selectionPosition]] [[getModelInfo]] [[getObjectType]] [[cursorObject]] [[selectionNames]] [[animationNames]] [[createVehicle]] [[enableSimulation]] [[hideObject]] [[getMissionPath]] [[allLODs]] [[Arma 3: Simple Objects]] [[Arma 3: createSimpleObject/objects]]
|  |= MPBEHAVIOUR
}}
}}


<h3 style='display:none'>Bottom Section</h3>
{{Note
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
|user= Killzone_Kid
[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]
|timestamp= 20160418200300
[[Category:Arma_3:_New_Scripting_Commands_List|{{uc:{{PAGENAME}}}}]]
|text= The easiest way to correctly place simple object is to create normal object of the same shape from class (if possible), then copy [[getPosWorld]], [[vectorDir]] and [[vectorUp]] from it. Then create the simple object and apply copied values to it, this will position simple object exactly as normal object was positioned:
<sqf>
private _heli = "B_Heli_Light_01_F" createVehicleLocal (player getRelPos [10, 0]);
private _position = getPosWorld _heli;
private _vectorDirUp = [vectorDir _heli, vectorUp _heli];
private _model = getModelInfo _heli select 1;
deleteVehicle _heli;
private _simpleHeli = createSimpleObject [_model, _position];
_simpleHeli setVectorDirAndUp _vectorDirUp;
</sqf>
}}


<h3 style='display:none'>Notes</h3>
{{Note
<dl class="command_description">
|user= Waffle SS.
<!-- BEGIN Note Section -->
|timestamp= 20160428181000
<!-- END Note Section -->
|text= Models from within the mission file/folder can be created, but full system path is needed. See [[getMissionPath]]
</dl>
}}


<h3 style="display:none">Bottom Section</h3>
{{Note
 
|user= Waffle SS.
<!-- CONTINUE Notes -->
|timestamp= 20160511012800
<dl class="command_description">
|text= [[simulationEnabled]] returns false.
<dd class="notedate">Posted on April 18, 2016 - 20:03 (UTC)</dd>
}}
<dt class="note">[[User:Killzone Kid|Killzone Kid]]</dt>
<dd class="note">The easiest way to correctly place simple object is to create normal object of the same shape from class (if possible), then copy [[getPosWorld]], [[vectorDir]] and [[vectorUp]] from it. Then create the simple object and apply copied values to it, this will position simple object exactly as normal object was positioned:
<code>_heli = "B_Heli_Light_01_F" [[createVehicleLocal]] ([[player]] [[getRelPos]] [10, 0]);
_position = [[getPosWorld]] _heli;
_vectorDirUp = <nowiki>[</nowiki>[[vectorDir]] _heli, [[vectorUp]] _heli];
_model = [[getModelInfo]] _heli [[select]] 1;
[[deleteVehicle]] _heli;
_simpleHeli = [[createSimpleObject]] [_model, _position];
_simpleHeli [[setVectorDirAndUp]] _vectorDirUp;</code>
</dd>
</dl>
<!-- DISCONTINUE Notes -->
 
<!-- CONTINUE Notes -->
<dl class="command_description">
<dd class="notedate">Posted on April 28, 2016 - 18:10 (UTC)</dd>
<dt class="note">[[User:Waffle SS.|Waffle SS.]]</dt>
<dd class="note">
Models from within the mission file/folder can be created, but full system path is needed. Use:
<code>([[str]] [[missionConfigFile]] [[select]] [0, [[count]] [[str]] [[missionConfigFile]] - 15]) + "myModel.p3d"
//mission folder path code from: http://killzonekid.com/arma-scripting-tutorials-mission-root/</code>
</dd>
</dl>
<!-- DISCONTINUE Notes -->


<!-- CONTINUE Notes -->
{{Note
<dl class="command_description">
|user= Warka
<dd class="notedate">Posted on May 11, 2016 - 01:28 (UTC)</dd>
|timestamp= 20160905151000
<dt class="note">[[User:Waffle SS.|Waffle SS.]]</dt>
|text= There is a section in function library dedicated to simple object creation and interaction. It's purpose is to simplify the operations:
<dd class="note">
[[simulationEnabled]] returns false.
</dd>
</dl>
<!-- DISCONTINUE Notes -->
 
<!-- CONTINUE Notes -->
<dl class="command_description">
<dd class="notedate">Posted on September 5, 2016 - 15:10 (UTC)</dd>
<dt class="note">[[User:Warka|Warka]]</dt>
<dd class="note">
There is a section in function library dedicated to simple object creation and interaction. It's purpose is to simplify the operations:
* [[BIS_fnc_createSimpleObject]]
* [[BIS_fnc_createSimpleObject]]
** creates simple object according to the supplied data
** creates simple object according to the supplied data
Line 128: Line 143:
* [[BIS_fnc_adjustSimpleObject]]
* [[BIS_fnc_adjustSimpleObject]]
** adjusts simple object to looks as close to the non-simple object as possible
** adjusts simple object to looks as close to the non-simple object as possible
** function is internally called from the 'bis_fnc_createSimpleObject', you won't probably need to call this function directly
** function is internally called from the 'BIS_fnc_createSimpleObject', you won't probably need to call this function directly


Check the function headers for more info about the input parameters and possibilities.
Check the function headers for more info about the input parameters and possibilities.
</dd>
}}
</dl>
 
<!-- DISCONTINUE Notes -->
{{Note
|user= POLPOX
|timestamp= 20240127232310
|text= Before circa Arma 3 2.07: The path must '''not''' start with a backslash:
{{{!}}
{{!}} {{Icon|unchecked}}
{{!}} {{hl|"'''\'''a3\armor_f_beta...}}
{{!}}-
{{!}} {{Icon|checked}}
{{!}} {{hl|"a3\armor_f_beta...}}
{{!}}}
}}

Latest revision as of 17:05, 29 January 2024

Hover & click on the images for description

Description

Description:
Create object with given shape defined as path to .p3d model. Supported LODs include Geometry, Fire Geometry, Roadway, View Geometry and ShadowVolume. Supported features include collision, texturing, animation, penetration, AI spotting occlusion, and surface specific sounds (like footsteps). Unsupported features include PhysX, damage, AI pathfinding (causes walking through walls), and built-in lights.

Given the simulation limitations, global decorative objects can be created with very little network traffic. Objects that could be exclusively created with this command are: trees, bushes, rocks, bridges, roads, vehicle wrecks, custom models in mission, and other objects without a class in config. The height of the placement position might need to be adjusted experimentally.


Please note that:

  • addAction does not work with simple objects.
  • objects created with Syntax 1 cannot be textured. Some objects may also have inverted default direction.
  • objects created with Syntax 2 can be textured. The default direction should match the direction of the object if it was created with createVehicle.
  • only as of Arma 3 logo black.png1.68 do simple objects support getVariable and setVariable.
Groups:
Object Manipulation

Syntax

Syntax:
createSimpleObject [shapeName, positionWorld, local]
Parameters:
shapeName: String - path to the 3d model (can be obtained with getModelInfo command)
positionWorld: Array format PositionASL - placement position by the model centre's position (see getPosWorld)
since Arma 3 logo black.png1.96
local: Boolean - (Optional, default false) true to create a local instance only
Return Value:
Object - created simple object

Alternative Syntax

Syntax:
createSimpleObject [className, positionASL, local]
Parameters:
className: String - CfgVehicles class name
positionASL: Array format PositionASL - placement position
since Arma 3 logo black.png1.96
local: Boolean - (Optional, default false) true to create a local instance only
Return Value:
Object - created simple object

Examples

Example 1:
private _pos = player getRelPos [10, 0]; private _tank = createSimpleObject ["a3\armor_f_beta\apc_tracked_01\apc_tracked_01_rcws_f.p3d", _pos]; _tank setPos (_pos vectorAdd (getPosWorld _tank vectorDiff (_tank modelToWorld [0,0,0]))); _tank hideSelection ["zasleh", true]; _tank hideSelection ["zasleh2", true]; _tank hideSelection ["clan", true]; _tank animate ["Wheel_podkoloL3", 0.5, true]; _tank animate ["Wheel_podkoloL6", 0.5, true];
Example 2:
private _pos = player getRelPos [10, 0]; private _tank = createSimpleObject ["B_APC_Tracked_01_CRV_F", AGLToASL _pos]; _tank setObjectTexture [0, "#(rgb,8,8,3)color(0,1,0,0.01)"]; _tank hideSelection ["zasleh", true]; _tank hideSelection ["zasleh2", true]; _tank hideSelection ["clan", true]; _tank animate ["Wheel_podkoloL3", 0.5, true]; _tank animate ["Wheel_podkoloL6", 0.5, true];
Example 3:
Create a pond:
private _waterTileModel = "a3\structures_f_enoch\Water\pond_big_01.p3d"; // visual only - this pond is a hard surface private _tileSize = 18; // width & height private _tileX = 10; private _tileY = 5; private _bottomLeftCorner = getPosWorld player; private _tilePos = -1; private _tiles = []; private _tile = objNull; for "_y" from 0 to (_tileY - 1) do { for "_x" from 0 to (_tileX - 1) do { _tilePos = _bottomLeftCorner vectorAdd [_x * _tileSize, _y * _tileSize, 0]; _tile = createSimpleObject [_waterTileModel, _tilePos]; _tiles pushBack _tile; }; }; sleep 10; { deleteVehicle _x } forEach _tiles;

Additional Information

See also:
isSimpleObject hideSelection selectionPosition getModelInfo getObjectType cursorObject selectionNames animationNames createVehicle enableSimulation hideObject getMissionPath allLODs Arma 3: Simple Objects Arma 3: createSimpleObject/objects

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note
Killzone_Kid - c
Posted on Apr 18, 2016 - 20:03 (UTC)
The easiest way to correctly place simple object is to create normal object of the same shape from class (if possible), then copy getPosWorld, vectorDir and vectorUp from it. Then create the simple object and apply copied values to it, this will position simple object exactly as normal object was positioned:
private _heli = "B_Heli_Light_01_F" createVehicleLocal (player getRelPos [10, 0]); private _position = getPosWorld _heli; private _vectorDirUp = [vectorDir _heli, vectorUp _heli]; private _model = getModelInfo _heli select 1; deleteVehicle _heli; private _simpleHeli = createSimpleObject [_model, _position]; _simpleHeli setVectorDirAndUp _vectorDirUp;
Waffle SS. - c
Posted on Apr 28, 2016 - 18:10 (UTC)
Models from within the mission file/folder can be created, but full system path is needed. See getMissionPath
Waffle SS. - c
Posted on May 11, 2016 - 01:28 (UTC)
simulationEnabled returns false.
Warka - c
Posted on Sep 05, 2016 - 15:10 (UTC)
There is a section in function library dedicated to simple object creation and interaction. It's purpose is to simplify the operations:
  • BIS_fnc_createSimpleObject
    • creates simple object according to the supplied data
    • you can supply p3d path, class name or data you get from scanning a non-simple object
  • BIS_fnc_simpleObjectData
    • gathers and returns data about the non-simple object
    • data can be then used to create simple object
  • BIS_fnc_replaceWithSimpleObject
    • replaces non-simple object with simple object on the scene
    • do not use it in large scale in MP missions as it is not network efficient
  • BIS_fnc_adjustSimpleObject
    • adjusts simple object to looks as close to the non-simple object as possible
    • function is internally called from the 'BIS_fnc_createSimpleObject', you won't probably need to call this function directly
Check the function headers for more info about the input parameters and possibilities.
POLPOX - c
Posted on Jan 27, 2024 - 23:23 (UTC)
Before circa Arma 3 2.07: The path must not start with a backslash:
Unchecked "\a3\armor_f_beta...
Checked "a3\armor_f_beta...