{"name":"Arma 3: Animals: Override Default Animal Behaviour Via Script","title":"Arma 3: Animals: Override Default Animal Behaviour Via Script","type":"topic","url":"https://community.bistudio.com/wiki/Arma_3:_Animals:_Override_Default_Animal_Behaviour_Via_Script","revid":370875,"updated":"2025-02-21T10:44:01Z","aliases":["Arma 3 Animals: Override Default Animal Behaviour Via Script"],"markdown":"Animals in Arma 3 roam freely according to their FSM; they autonomously walk, stop, eat, flee etc.\nIn order to control them fully you will need to override their default behaviour and manually guide them, all with a bit of scripting.\n\n### Animal Creation\n\nAnimal classnames can be found on the Arma 3: CfgVehicles Animals page.\n\n#### createAgent Command\n\nSpawning animals via createAgent is the best way how to have control over them in your mission.\nAn **agent** is a \"light AI\" that doesn't have all the abilities/intelligence of a \"normal\" AI unit created via createUnit;\ntherefore, they **cannot** be controlled via commands such as doMove and doStop. However, low-level commands such as moveTo or setDestination will work.\n\nFor a basic example see Example script.\n\n#### Animals Module\n\nThe Animals module can be found in Eden Editor in the Modules page (<kbd>F5</kbd>), under the Sites category.\n\nInsert the module in editor, set the desired parameters and you have animals in your mission.\nSpawned animals will be for mission decoration purpose instead of heavily-scripted behaviour.\n\n### Disable animal's scripted behaviour\n\nYou can disable animal's scripted behaviour using the following:\n\n```sqf\n_animal setVariable [\"BIS_fnc_animalBehaviour_disable\", true];\n```\n\n### Animations\n\nAnimations can be played using playMove, playMoveNow or switchMove. Their names are quite self-explanatory.\n\n> [!IMPORTANT]\n> Animals will remain in the same animation cycle until manually changed!\n\n#### Dog\n\n```sqf\n_dog playMove \"Dog_Stop\";\n_dog playMove \"Dog_Sit\";\n_dog playMove \"Dog_Walk\";\n_dog playMove \"Dog_Run\";\n_dog playMove \"Dog_Sprint\";\n_dog playMove \"Dog_Idle_Stop\"; // wandering, default behaviour\n```\n\n- \"Dog_Idle_Stop\"\n- \"Dog_Idle_Walk\"\n- \"Dog_Die\"\n- \"Dog_Run\"\n- \"Dog_Sprint\"\n- \"Dog_Sit\"\n- \"Dog_Stop\"\n- \"Dog_Idle_01\"\n- \"Dog_Idle_02\"\n- \"Dog_Idle_03\"\n- \"Dog_Idle_04\"\n- \"Dog_Idle_05\"\n- \"Dog_Idle_06\"\n- \"Dog_Idle_07\"\n- \"Dog_Idle_08\"\n- \"Dog_Idle_09\"\n- \"Dog_Idle_10\"\n- \"Dog_Idle_Sit01\"\n- \"Dog_Idle_Sit02\"\n- \"Dog_Idle_Sit03\"\n- \"Dog_Idle_Sit04\"\n- \"Dog_Idle_Sit05\"\n- \"Dog_Idle_Sit06\"\n- \"Dog_Idle_Sit07\"\n- \"Dog_Idle_Sit08\"\n- \"Dog_Idle_Bark\"\n- \"Dog_Idle_Growl\"\n- \"Dog_Idle_Walk\"\n- \"Dog_Idle_Run\"\n- \"Dog_Idle_Sprint\"\n- \"Dog_TurnL\"\n- \"Dog_TurnR\"\n\n#### Sheep\n\n```sqf\n_sheep playMove \"Sheep_Stop\";\n_sheep playMove \"Sheep_Walk\";\n_sheep playMove \"Sheep_Run\";\n_sheep playMove \"Sheep_Idle_Stop\"; // wandering, default behaviour\n```\n\n#### Goat\n\n```sqf\n_goat playMove \"Goat_Stop\";\n_goat playMove \"Goat_Walk\";\n_goat playMove \"Goat_Run\";\n_goat playMove \"Goat_Idle_Stop\"; // wandering, default behaviour\n```\n\n#### Rabbit\n\n```sqf\n_rabbit playMove \"Rabbit_Stop\";\n_rabbit playMove \"Rabbit_Hop\";\n_rabbit playMove \"Rabbit_Idle_Stop\"; // wandering, default behaviour\n```\n\n#### Cockerel\n\n```sqf\n_cock playMove \"Cock_Stop\";\n_cock playMove \"Cock_Walk\";\n_cock playMove \"Cock_Run\";\n_cock playMove \"Cock_Idle_Stop\"; // wandering, default behaviour\n```\n\n#### Hen\n\n```sqf\n_hen playMove \"Hen_Stop\";\n_hen playMove \"Hen_Walk\";\n_hen playMove \"Hen_Idle_Stop\"; // wandering, default behaviour\n```\n\n#### Snake\n\n```sqf\n_snake playMove \"Snakes_Stop\";\n_snake playMove \"Snakes_Move\";\n_snake playMove \"Snakes_Idle_Stop\"; // wandering, default behaviour\n```\n\n### Examples\n\n#### Script\n\nSimple example for a dog to follow the player:\n\n```sqf\n// spawn dog\n_dog = createAgent [\"Fin_random_F\", getPosATL player, [], 5, \"NONE\"];\n\n// disable animal behaviour\n_dog setVariable [\"BIS_fnc_animalBehaviour_disable\", true];\n\n// following loop\n[_dog] spawn {\n    params [\"_dog\"];\n\n    // force dog to sprint\n    _dog playMove \"Dog_Sprint\";\n\n    while { sleep 3; alive _dog } do\n    {\n        _dog moveTo getPosATL player;\n    };\n};\n```\n\nSee in action: [YouTube](https://www.youtube.com/watch?v=0X8oumNj9kc)","sections":[{"heading":null,"level":1,"markdown":"Animals in Arma 3 roam freely according to their FSM; they autonomously walk, stop, eat, flee etc.\nIn order to control them fully you will need to override their default behaviour and manually guide them, all with a bit of scripting."},{"heading":"Animal Creation","level":3,"markdown":"Animal classnames can be found on the Arma 3: CfgVehicles Animals page."},{"heading":"createAgent Command","level":4,"markdown":"Spawning animals via createAgent is the best way how to have control over them in your mission.\nAn **agent** is a \"light AI\" that doesn't have all the abilities/intelligence of a \"normal\" AI unit created via createUnit;\ntherefore, they **cannot** be controlled via commands such as doMove and doStop. However, low-level commands such as moveTo or setDestination will work.\n\nFor a basic example see Example script."},{"heading":"Animals Module","level":4,"markdown":"The Animals module can be found in Eden Editor in the Modules page (<kbd>F5</kbd>), under the Sites category.\n\nInsert the module in editor, set the desired parameters and you have animals in your mission.\nSpawned animals will be for mission decoration purpose instead of heavily-scripted behaviour."},{"heading":"Disable animal's scripted behaviour","level":3,"markdown":"You can disable animal's scripted behaviour using the following:\n\n```sqf\n_animal setVariable [\"BIS_fnc_animalBehaviour_disable\", true];\n```"},{"heading":"Animations","level":3,"markdown":"Animations can be played using playMove, playMoveNow or switchMove. Their names are quite self-explanatory.\n\n> [!IMPORTANT]\n> Animals will remain in the same animation cycle until manually changed!"},{"heading":"Dog","level":4,"markdown":"```sqf\n_dog playMove \"Dog_Stop\";\n_dog playMove \"Dog_Sit\";\n_dog playMove \"Dog_Walk\";\n_dog playMove \"Dog_Run\";\n_dog playMove \"Dog_Sprint\";\n_dog playMove \"Dog_Idle_Stop\"; // wandering, default behaviour\n```\n\n- \"Dog_Idle_Stop\"\n- \"Dog_Idle_Walk\"\n- \"Dog_Die\"\n- \"Dog_Run\"\n- \"Dog_Sprint\"\n- \"Dog_Sit\"\n- \"Dog_Stop\"\n- \"Dog_Idle_01\"\n- \"Dog_Idle_02\"\n- \"Dog_Idle_03\"\n- \"Dog_Idle_04\"\n- \"Dog_Idle_05\"\n- \"Dog_Idle_06\"\n- \"Dog_Idle_07\"\n- \"Dog_Idle_08\"\n- \"Dog_Idle_09\"\n- \"Dog_Idle_10\"\n- \"Dog_Idle_Sit01\"\n- \"Dog_Idle_Sit02\"\n- \"Dog_Idle_Sit03\"\n- \"Dog_Idle_Sit04\"\n- \"Dog_Idle_Sit05\"\n- \"Dog_Idle_Sit06\"\n- \"Dog_Idle_Sit07\"\n- \"Dog_Idle_Sit08\"\n- \"Dog_Idle_Bark\"\n- \"Dog_Idle_Growl\"\n- \"Dog_Idle_Walk\"\n- \"Dog_Idle_Run\"\n- \"Dog_Idle_Sprint\"\n- \"Dog_TurnL\"\n- \"Dog_TurnR\""},{"heading":"Sheep","level":4,"markdown":"```sqf\n_sheep playMove \"Sheep_Stop\";\n_sheep playMove \"Sheep_Walk\";\n_sheep playMove \"Sheep_Run\";\n_sheep playMove \"Sheep_Idle_Stop\"; // wandering, default behaviour\n```"},{"heading":"Goat","level":4,"markdown":"```sqf\n_goat playMove \"Goat_Stop\";\n_goat playMove \"Goat_Walk\";\n_goat playMove \"Goat_Run\";\n_goat playMove \"Goat_Idle_Stop\"; // wandering, default behaviour\n```"},{"heading":"Rabbit","level":4,"markdown":"```sqf\n_rabbit playMove \"Rabbit_Stop\";\n_rabbit playMove \"Rabbit_Hop\";\n_rabbit playMove \"Rabbit_Idle_Stop\"; // wandering, default behaviour\n```"},{"heading":"Cockerel","level":4,"markdown":"```sqf\n_cock playMove \"Cock_Stop\";\n_cock playMove \"Cock_Walk\";\n_cock playMove \"Cock_Run\";\n_cock playMove \"Cock_Idle_Stop\"; // wandering, default behaviour\n```"},{"heading":"Hen","level":4,"markdown":"```sqf\n_hen playMove \"Hen_Stop\";\n_hen playMove \"Hen_Walk\";\n_hen playMove \"Hen_Idle_Stop\"; // wandering, default behaviour\n```"},{"heading":"Snake","level":4,"markdown":"```sqf\n_snake playMove \"Snakes_Stop\";\n_snake playMove \"Snakes_Move\";\n_snake playMove \"Snakes_Idle_Stop\"; // wandering, default behaviour\n```"},{"heading":"Examples","level":3,"markdown":""},{"heading":"Script","level":4,"markdown":"Simple example for a dog to follow the player:\n\n```sqf\n// spawn dog\n_dog = createAgent [\"Fin_random_F\", getPosATL player, [], 5, \"NONE\"];\n\n// disable animal behaviour\n_dog setVariable [\"BIS_fnc_animalBehaviour_disable\", true];\n\n// following loop\n[_dog] spawn {\n    params [\"_dog\"];\n\n    // force dog to sprint\n    _dog playMove \"Dog_Sprint\";\n\n    while { sleep 3; alive _dog } do\n    {\n        _dog moveTo getPosATL player;\n    };\n};\n```\n\nSee in action: [YouTube](https://www.youtube.com/watch?v=0X8oumNj9kc)"}],"categories":["Arma 3: Editing","Arma 3: Tutorials"],"groups":["General"]}