Animals: Override Default Animal Behaviour Via Script – Arma 3
Lou Montana (talk | contribs) m (Lou Montana moved page Arma 3 Animals: Override Default Animal Behaviour Via Script to Arma 3: Animals: Override Default Animal Behaviour Via Script: Text replacement - "^Arma 3 " to "Arma 3: ") |
Lou Montana (talk | contribs) m (Text replacement - "Category:Eden Editor" to "Eden Editor") |
||
(10 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{{TOC|side}} | {{TOC|side}} | ||
Animals in {{arma3}} roam freely according to their [[FSM]]; they autonomously walk, stop, eat, flee etc. | 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. | In order to control them fully you will need to override their default behaviour and manually guide them, all with a bit of scripting. | ||
== Animal | == Animal Creation == | ||
Animal classnames can be found on the [[Arma 3 CfgVehicles Animals]] page. | Animal classnames can be found on the [[Arma 3 CfgVehicles Animals]] page. | ||
=== createAgent | === createAgent Command === | ||
Spawning animals ''via'' [[createAgent]] is the best way how to have control over them in your mission.<br> | Spawning animals ''via'' [[createAgent]] is the best way how to have control over them in your mission.<br> | ||
Line 18: | Line 16: | ||
For a basic example see [[#Example script|Example script]]. | For a basic example see [[#Example script|Example script]]. | ||
<div | <div class="float-right">[[File:arma3 animals module in menu.png|thumb|175px|Animals Module location]]</div> | ||
=== Animals | === Animals Module === | ||
The Animals module can be found in [[Eden Editor]] in the Modules page (F5), under the Sites category. | The Animals module can be found in [[:Category:Eden Editor|Eden Editor]] in the Modules page ({{Controls|F5}}), under the Sites category. | ||
Insert the module in editor, set the desired parameters and you have animals in your mission.<br> | Insert the module in editor, set the desired parameters and you have animals in your mission.<br> | ||
Line 30: | Line 28: | ||
You can disable [[BIS_fnc_animalBehaviour|animal's scripted behaviour]] using the following: | You can disable [[BIS_fnc_animalBehaviour|animal's scripted behaviour]] using the following: | ||
<sqf>_animal setVariable ["BIS_fnc_animalBehaviour_disable", true];</sqf> | |||
Line 36: | Line 34: | ||
Animations can be played using [[playMove]], [[playMoveNow]] or [[switchMove]]. Their names are quite self-explanatory. | 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!}} | ||
=== Dog === | === Dog === | ||
<sqf> | |||
_dog playMove "Dog_Stop"; | |||
_dog playMove "Dog_Sit"; | |||
_dog playMove "Dog_Walk"; | |||
_dog playMove "Dog_Run"; | |||
_dog playMove "Dog_Sprint"; | |||
_dog playMove "Dog_Idle_Stop"; // wandering, default behaviour | |||
</sqf> | |||
<spoiler text="Show all dog animations"> | |||
{{Columns|4| | |||
* "Dog_Idle_Stop" | |||
* "Dog_Idle_Walk" | |||
* "Dog_Die" | |||
* "Dog_Run" | |||
* "Dog_Sprint" | |||
* "Dog_Sit" | |||
* "Dog_Stop" | |||
* "Dog_Idle_01" | |||
* "Dog_Idle_02" | |||
* "Dog_Idle_03" | |||
* "Dog_Idle_04" | |||
* "Dog_Idle_05" | |||
* "Dog_Idle_06" | |||
* "Dog_Idle_07" | |||
* "Dog_Idle_08" | |||
* "Dog_Idle_09" | |||
* "Dog_Idle_10" | |||
* "Dog_Idle_Sit01" | |||
* "Dog_Idle_Sit02" | |||
* "Dog_Idle_Sit03" | |||
* "Dog_Idle_Sit04" | |||
* "Dog_Idle_Sit05" | |||
* "Dog_Idle_Sit06" | |||
* "Dog_Idle_Sit07" | |||
* "Dog_Idle_Sit08" | |||
* "Dog_Idle_Bark" | |||
* "Dog_Idle_Growl" | |||
* "Dog_Idle_Walk" | |||
* "Dog_Idle_Run" | |||
* "Dog_Idle_Sprint" | |||
* "Dog_TurnL" | |||
* "Dog_TurnR" | |||
}} | |||
</spoiler> | |||
=== Sheep === | === Sheep === | ||
<sqf> | |||
_sheep playMove "Sheep_Stop"; | |||
_sheep playMove "Sheep_Walk"; | |||
_sheep playMove "Sheep_Run"; | |||
_sheep playMove "Sheep_Idle_Stop"; // wandering, default behaviour | |||
</sqf> | |||
=== Goat === | === Goat === | ||
<sqf> | |||
_goat playMove "Goat_Stop"; | |||
_goat playMove "Goat_Walk"; | |||
_goat playMove "Goat_Run"; | |||
_goat playMove "Goat_Idle_Stop"; // wandering, default behaviour | |||
</sqf> | |||
=== Rabbit === | === Rabbit === | ||
<sqf> | |||
_rabbit playMove "Rabbit_Stop"; | |||
_rabbit playMove "Rabbit_Hop"; | |||
_rabbit playMove "Rabbit_Idle_Stop"; // wandering, default behaviour | |||
</sqf> | |||
=== Cockerel === | === Cockerel === | ||
<sqf> | |||
_cock playMove "Cock_Stop"; | |||
_cock playMove "Cock_Walk"; | |||
_cock playMove "Cock_Run"; | |||
_cock playMove "Cock_Idle_Stop"; // wandering, default behaviour | |||
</sqf> | |||
=== Hen === | === Hen === | ||
<sqf> | |||
_hen playMove "Hen_Stop"; | |||
_hen playMove "Hen_Walk"; | |||
_hen playMove "Hen_Idle_Stop"; // wandering, default behaviour | |||
</sqf> | |||
=== Snake === | === Snake === | ||
<sqf> | |||
_snake playMove "Snakes_Stop"; | |||
_snake playMove "Snakes_Move"; | |||
_snake playMove "Snakes_Idle_Stop"; // wandering, default behaviour | |||
</sqf> | |||
== | == Examples == | ||
=== Script === | |||
Simple example for a dog to follow the player: | Simple example for a dog to follow the player: | ||
<sqf> | |||
// spawn dog | |||
_dog = createAgent ["Fin_random_F", getPosATL player, [], 5, "NONE"]; | |||
// disable animal behaviour | |||
_dog setVariable ["BIS_fnc_animalBehaviour_disable", true]; | |||
// following loop | |||
[_dog] spawn { | |||
params ["_dog"]; | |||
// force dog to sprint | |||
_dog playMove "Dog_Sprint"; | |||
while { sleep 3; alive _dog } do | |||
{ | |||
_dog moveTo getPosATL player; | |||
}; | |||
}; | |||
</sqf> | |||
See in action: {{Link|https://www.youtube.com/watch?v{{=}}0X8oumNj9kc|YouTube}} | |||
{{GameCategory|arma3|Editing}} | {{GameCategory|arma3|Editing}} | ||
{{GameCategory|arma3|Tutorials}} |
Revision as of 14:27, 9 July 2023
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.
Animal Creation
Animal classnames can be found on the Arma 3 CfgVehicles Animals page.
createAgent Command
Spawning animals via createAgent 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 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.
For a basic example see Example script.
Animals Module
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.
Disable animal's scripted behaviour
You can disable animal's scripted behaviour using the following:
Animations
Animations can be played using playMove, playMoveNow or switchMove. Their names are quite self-explanatory.
Dog
- "Dog_Idle_Stop"
- "Dog_Idle_Walk"
- "Dog_Die"
- "Dog_Run"
- "Dog_Sprint"
- "Dog_Sit"
- "Dog_Stop"
- "Dog_Idle_01"
- "Dog_Idle_02"
- "Dog_Idle_03"
- "Dog_Idle_04"
- "Dog_Idle_05"
- "Dog_Idle_06"
- "Dog_Idle_07"
- "Dog_Idle_08"
- "Dog_Idle_09"
- "Dog_Idle_10"
- "Dog_Idle_Sit01"
- "Dog_Idle_Sit02"
- "Dog_Idle_Sit03"
- "Dog_Idle_Sit04"
- "Dog_Idle_Sit05"
- "Dog_Idle_Sit06"
- "Dog_Idle_Sit07"
- "Dog_Idle_Sit08"
- "Dog_Idle_Bark"
- "Dog_Idle_Growl"
- "Dog_Idle_Walk"
- "Dog_Idle_Run"
- "Dog_Idle_Sprint"
- "Dog_TurnL"
- "Dog_TurnR"
Sheep
Goat
Rabbit
Cockerel
Hen
Snake
Examples
Script
Simple example for a dog to follow the player:
See in action: YouTube