Animals in {{arma3}} roam freely according to their [[FSM]]; they autonomously walk, stop, eat, flee etc.
In order to control them fully you will need to override their default behaviour and manually guide them, all with a bit of scripting.
{{note|'''Please note, this feature is WIP and works only in Development Build 1.55.133700 and later!'''}}
----
== Introduction ==
== Animal Creation ==
Current system of animal behaviour is that animals are randomly idling / moving around when spawned. This is caused by changes on engine side to save some performance. However, many people from community want to be able to control animals via script in some reasonable manner. So I started to work on some tweaks of animal animation configs which will offer this possibility to them. This page is overview of this feature and tutorial, how this behaviour can be achieved.
Animal classnames can be found on the [[Arma 3 CfgVehicles Animals]] page.
At the moment, the tweaks are made for dog animation config only, because dog has the most variable movement possibilities and is mostly requested by community. Don't worry, other animals will be tweaked as well.
=== createAgent Command ===
== Basics ==
Spawning animals ''via'' [[createAgent]] is the best way how to have control over them in your mission.<br>
An '''agent''' is a "light AI" that doesn't have all the abilities/intelligence of a "normal" AI unit created ''via'' [[createUnit]];
therefore, they '''cannot''' be controlled via commands such as [[doMove]] and [[doStop]]. However, low-level commands such as [[moveTo]] or [[setDestination]] will work.
Animals can be spawned via multiple ways. Here I will explain you which ways will work with my recent tweaks, which partly and which not.
For a basic example see [[#Example script|Example script]].
=== Module Animals from Sites category ===
<div style="float: right">[[File:arma3 animals module in menu.png|thumb|175px|Animals Module location]]</div>
=== Animals Module ===
Probably the easiest way how to spawn animals. Just insert the module in editor, set the desired parameters and you have animals in your mission. Unfortunately, animals spawned this way '''can't be controlled via script''' in any way and will only randomly move around depending on the area you set.
The Animals module can be found in [[Eden Editor]] in the Modules page (F5), under the Sites category.
=== Spawn via createAgent command ===
Insert the module in editor, set the desired parameters and you have animals in your mission.<br>
Spawned animals will be for mission decoration purpose instead of heavily-scripted behaviour.
Spawning animals via scripting command createAgent is another way how to have animals in your mission. And yes, animals created this way can be controled in some limited way. As the animal AI is controlled by AIAgent, it won't be able to be controlled via commands such as doMove and doStop and will roam randomly around. But you can determine, in which state (like move, stop, etc.) the animal will move.
Another way to spawn animal is using createUnit command. This is probably most interesting for you, modders and mission creators. In this mode the AI is handled differently than agent so the animal won't randomly change directions and will face same direction in which it has been spawned. But the cool point is, you can command the animal via doMove and doStop commands, so you will be able to control it in any way you want (creating waypoints, following the player, etc.)
You can disable [[BIS_fnc_animalBehaviour|animal's scripted behaviour]] using the following:
Additionaly the animal can be groupped with player and thus will be able to obey some basic commands like Move via command menu.
== Animations ==
'''Example:''' <syntaxhighlight lang="cpp">_dog = group player createUnit ["Fin_random_F", getPos player, [], 5, "CAN_COLLIDE"];</syntaxhighlight>
Animations can be played using [[playMove]], [[playMoveNow]] or [[switchMove]]. Their names are quite self-explanatory.
{{ Feature | important | Animals will remain in the same animation cycle until manually changed! }}
== Usage ==
=== Dog ===
It is very simple. All you need is playMove or switchMove commands and knowledge of available animation states, which override the default animal behaviour (see [[#Currently available animals|list of currently available animals]]). When you will do that, remember, the animal will remain in that state until you change it via script. And also keep in mind, that the animal '''agent''' (spawned via createAgent command) will be affected by FSM if you won't disbale it via [[BIS_fnc_animalBehaviour|BIS_fnc_animalBehaviour_disable]] variable!
You can try this mission - simply create mission for VR map, copy and paste / create following two files and preview in editor. All dog actions are controllable via action menu. See [https://www.youtube.com/watch?v=0X8oumNj9kc this video] captured from this example mission.
Animals in Arma 3 roam freely according to their FSM; they autonomously walk, stop, eat, flee etc.
In order to control them fully you will need to override their default behaviour and manually guide them, all with a bit of scripting.
Spawning animals viacreateAgent is the best way how to have control over them in your mission.
An agent is a "light AI" that doesn't have all the abilities/intelligence of a "normal" AI unit created viacreateUnit;
therefore, they cannot be controlled via commands such as doMove and doStop. However, low-level commands such as moveTo or setDestination will work.
The Animals module can be found in Eden Editor in the Modules page (F5), under the Sites category.
Insert the module in editor, set the desired parameters and you have animals in your mission.
Spawned animals will be for mission decoration purpose instead of heavily-scripted behaviour.