{"name":"createAgent","operator":null,"title":"createAgent","type":"command","url":"https://community.bistudio.com/wiki/createAgent","revid":378352,"updated":"2026-04-02T16:33:41Z","groups":["Object Manipulation"],"status":"ok","replaced_by":[],"games":[{"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":"arma2","name":"Arma 2","version":"1.00"},"arma3_since":"0.50","branch":null,"locality":{"argument":null,"effect":"global","server_exec":false},"exec":null,"description":"Creates an agent of the given type. An agent does not have a group or leader or the standard soldier FSM associated with it - for instance, an enemy soldier spawned as an agent has limited AI and will do nothing when fired upon - which can be useful to limit the amount of AI processing being done in a mission with very large numbers of \"AI\". Animals are also commonly created as agents.\n\n> [!NOTE]\n> - Players assigned to an agent using selectPlayer will be able to control the agent, operate weapons and other actions, but will not be able to access their inventory using the gear screen.\n> - To create objects of type `\"Logic\"`, use createUnit.","syntaxes":[{"syntax":"createAgent [type, position, markers, placement, special]","since":null,"effect":null,"exec":null,"params":[{"name":"type","type":"String","optional":false,"default":null,"description":"class from CfgVehicles","types":["String"],"since":null,"text":"type: String - class from CfgVehicles"},{"name":"position","type":"Object or PositionAGL or Position2D","optional":false,"default":null,"description":"desired placement position","types":["Object","PositionAGL","Position2D"],"since":null,"text":"position: Object or PositionAGL or Position2D - desired placement position"},{"name":"markers","type":"Array of Strings","optional":false,"default":null,"description":"if the markers array contains any markers, the position is randomly picked from array of given markers plus desired placement position. If any of the markers were given z coordinate with setMarkerPos, the vehicle will also be created at given z coordinate.","types":["Array","String"],"since":null,"text":"markers: Array of Strings - if the markers array contains any markers, the position is randomly picked from array of given markers plus desired placement position. If any of the markers were given z coordinate with setMarkerPos, the vehicle will also be created at given z coordinate."},{"name":"placement","type":"Number","optional":false,"default":null,"description":"placement radius, the unit is randomly place in a circle with this radius","types":["Number"],"since":null,"text":"placement: Number - placement radius, the unit is randomly place in a circle with this radius"},{"name":"special","type":"String","optional":false,"default":null,"description":"one of:\n- `\"NONE\"` - will look for a suitable empty position near given position (subject to other placement params) before creating the agent\n- `\"CAN_COLLIDE\"` - creates the agent at given position (subject to other placement params), without checking if others objects can cross its 3D model","types":["String"],"since":null,"text":"special: String - one of:\n- `\"NONE\"` - will look for a suitable empty position near given position (subject to other placement params) before creating the agent\n- `\"CAN_COLLIDE\"` - creates the agent at given position (subject to other placement params), without checking if others objects can cross its 3D model"}],"returns":{"type":"Object","types":["Object"],"description":null,"text":"Object"},"form":"unary","operator":null,"left":null,"right":{"text":"[type, position, markers, placement, special]","types":["Array"]}}],"examples":[{"text":"```sqf\nprivate _agent = createAgent [\"B_Soldier_F\", getPosATL player, [], 0, \"NONE\"];\n```","code":["private _agent = createAgent [\"B_Soldier_F\", getPosATL player, [], 0, \"NONE\"];"]},{"text":"```sqf\nprivate _agent = createAgent [\"Snake_random_F\", ASLToAGL getPosASL player, [], 0, \"CAN_COLLIDE\"]; // Creates a snake at player's feet\n```","code":["private _agent = createAgent [\"Snake_random_F\", ASLToAGL getPosASL player, [], 0, \"CAN_COLLIDE\"]; // Creates a snake at player's feet"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["agent","agents","isAgent","forEachMemberAgent","execFSM","BIS_fnc_execFSM"],"notes":[{"user":"Killzone_Kid","date":"2014-09-29T20:03:00Z","text":"In Arma 3, default FSM is calling BIS_fnc_animalBehaviour script upon agent creation, which takes on some animal behavioural logic. The problem here is that it is almost impossible to make animal do what is told. Until now. Since Arma 3 v1.32 you can set *BIS_fnc_animalBehaviour_disable* variable on the agent at the moment of agent creation, to override the function.\n\n```sqf\ntr = createTrigger [\"EmptyDetector\", player modelToWorld [0, 10, 0]];\ntr setTriggerArea [5, 5, 0, true];\ntr setTriggerActivation [\"CIV\", \"PRESENT\", true];\nrabbits = [];\nprivate \"_r\";\nfor \"_i\" from 1 to 10 do {\n    _r = createAgent [\"Rabbit_F\", position tr, [], 0, \"NONE\"];\n    _r setVariable [\"BIS_fnc_animalBehaviour_disable\", true];\n    rabbits pushBack _r;\n};\ntr setTriggerStatements [\n    \"if (rabbits isEqualTo thisList) exitWith {\n        _r = thisList select floor random count thisList;\n        _r moveTo (_r modelToWorld [2.5 - random 5, 2.5 - random 5, 0]);\n    };\n    _esc = rabbits - thisList;\n    doStop _esc;\n    {_x moveTo position thisTrigger} forEach _esc;\n    systemChat str [time, _esc];\n    false\",\n    \"\",\n    \"\"\n];\n```"},{"user":"Waffle SS.","date":"2015-04-18T07:17:00Z","text":"Agents seem to use the same collision model that the player uses, unlike normal AI. Normal AI don't collide with objects, but agents are physically stopped by obstacles the same way players are. This also probably means agents cost more resources than normal AI."}],"categories":["Arma 2: New Scripting Commands","Arma 2: Operation Arrowhead: Scripting Commands","Arma 2: Scripting Commands","Arma 3: Scripting Commands","Command Group: Object Manipulation","Introduced with Arma 2 version 1.00","Scripting Commands","Scripting Commands: Global Effect","Take On Helicopters: Scripting Commands"]}