Animals: Override Default Animal Behaviour Via Script – Arma 3

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "\[\[[Cc]ategory:[ _]?Arma[ _]3:[ _]?([^|]*)]]" to "{{GameCategory|arma3|$1}}")
(Add dog animations list thanks to prababicka)
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{TOC|side}}
{{TOC|side}}
== Introduction ==
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 creation ==
== 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 command ===
=== 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 style="float: right; margin-left: 1.5em;">[[File:arma3 animals module in menu.png|150px]]</div><!-- cannot have AND size AND caption -->
<div style="float: right">[[File:arma3 animals module in menu.png|thumb|175px|Animals Module location]]</div>
=== Animals module ===
=== Animals Module ===


The Animals module can be found in [[Eden Editor]] in the Modules page (F5), under the Sites category.<br>
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.<br>
Insert the module in editor, set the desired parameters and you have animals in your mission.<br>
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.
{{ Important | Animals will remain in the same animation cycle until manually changed! }}
{{ Feature | important | Animals will remain in the same animation cycle until manually changed! }}


=== Dog ===
=== Dog ===


  _dog [[playMove]] "Dog_Stop";  
  _dog [[playMove]] "Dog_Stop";
  _dog [[playMove]] "Dog_Sit";
  _dog [[playMove]] "Dog_Sit";
  _dog [[playMove]] "Dog_Walk";
  _dog [[playMove]] "Dog_Walk";
  _dog [[playMove]] "Dog_Run";
  _dog [[playMove]] "Dog_Run";
  _dog [[playMove]] "Dog_Sprint";
  _dog [[playMove]] "Dog_Sprint";
  _dog [[playMove]] "Dog_Idle_Stop"; {{codecomment|// wandering, default behaviour}}
  _dog [[playMove]] "Dog_Idle_Stop"; {{cc|wandering, default behaviour}}
<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 ===
Line 52: Line 86:
  _sheep [[playMove]] "Sheep_Walk";
  _sheep [[playMove]] "Sheep_Walk";
  _sheep [[playMove]] "Sheep_Run";
  _sheep [[playMove]] "Sheep_Run";
  _sheep [[playMove]] "Sheep_Idle_Stop"; {{codecomment|// wandering, default behaviour}}
  _sheep [[playMove]] "Sheep_Idle_Stop"; {{cc|wandering, default behaviour}}


=== Goat ===
=== Goat ===
Line 59: Line 93:
  _goat [[playMove]] "Goat_Walk";
  _goat [[playMove]] "Goat_Walk";
  _goat [[playMove]] "Goat_Run";
  _goat [[playMove]] "Goat_Run";
  _goat [[playMove]] "Goat_Idle_Stop"; {{codecomment|// wandering, default behaviour}}
  _goat [[playMove]] "Goat_Idle_Stop"; {{cc|wandering, default behaviour}}


=== Rabbit ===
=== Rabbit ===
Line 65: Line 99:
  _rabbit [[playMove]] "Rabbit_Stop";
  _rabbit [[playMove]] "Rabbit_Stop";
  _rabbit [[playMove]] "Rabbit_Hop";
  _rabbit [[playMove]] "Rabbit_Hop";
  _rabbit [[playMove]] "Rabbit_Idle_Stop"; {{codecomment|// wandering, default behaviour}}
  _rabbit [[playMove]] "Rabbit_Idle_Stop"; {{cc|wandering, default behaviour}}


=== Cockerel ===
=== Cockerel ===
Line 72: Line 106:
  _cock [[playMove]] "Cock_Walk";
  _cock [[playMove]] "Cock_Walk";
  _cock [[playMove]] "Cock_Run";
  _cock [[playMove]] "Cock_Run";
  _cock [[playMove]] "Cock_Idle_Stop"; {{codecomment|// wandering, default behaviour}}
  _cock [[playMove]] "Cock_Idle_Stop"; {{cc|wandering, default behaviour}}


=== Hen ===
=== Hen ===
Line 78: Line 112:
  _hen [[playMove]] "Hen_Stop";
  _hen [[playMove]] "Hen_Stop";
  _hen [[playMove]] "Hen_Walk";
  _hen [[playMove]] "Hen_Walk";
  _hen [[playMove]] "Hen_Idle_Stop"; {{codecomment|// wandering, default behaviour}}
  _hen [[playMove]] "Hen_Idle_Stop"; {{cc|wandering, default behaviour}}


=== Snake ===
=== Snake ===
Line 84: Line 118:
  _snake [[playMove]] "Snakes_Stop";
  _snake [[playMove]] "Snakes_Stop";
  _snake [[playMove]] "Snakes_Move";
  _snake [[playMove]] "Snakes_Move";
  _snake [[playMove]] "Snakes_Idle_Stop"; {{codecomment|// wandering, default behaviour}}
  _snake [[playMove]] "Snakes_Idle_Stop"; {{cc|wandering, default behaviour}}




== Example script ==
== Examples ==
 
=== Script ===


Simple example for a dog to follow the player:
Simple example for a dog to follow the player:


  {{codecomment|// Spawn dog}}
  {{cc|Spawn dog}}
  _dog = [[createAgent]] ["Fin_random_F", [[getPosATL]] [[player]], [], 5, "NONE"];
  _dog = [[createAgent]] ["Fin_random_F", [[getPosATL]] [[player]], [], 5, "NONE"];
   
   
  {{codecomment|// Disable animal behaviour}}
  {{cc|Disable animal behaviour}}
  _dog [[setVariable]] ["BIS_fnc_animalBehaviour_disable", [[true]]];
  _dog [[setVariable]] ["BIS_fnc_animalBehaviour_disable", [[true]]];
   
   
  {{codecomment|// Following loop}}
  {{cc|Following loop}}
  [_dog] [[spawn]] {
  [_dog] [[spawn]] {
  [[params]] ["_dog"];
  [[params]] ["_dog"];
   
   
  {{codecomment|// Force dog to sprint}}
  {{cc|Force dog to sprint}}
  _dog [[playMove]] "Dog_Sprint";
  _dog [[playMove]] "Dog_Sprint";
   
   
Line 110: Line 146:
  };
  };


=== Mission ===


== Dog example mission ==
* Dog example mission: [https://mega.nz/#!4otnwA7T!R4HL77l_9Qwc_-3EgXZ95LqtV9g-W3ALXwru3JjQ6NQ download link] - [https://www.youtube.com/watch?v=0X8oumNj9kc YouTube link]
 
* Example mission: [https://mega.nz/#!4otnwA7T!R4HL77l_9Qwc_-3EgXZ95LqtV9g-W3ALXwru3JjQ6NQ download link]
* YouTube video: [https://www.youtube.com/watch?v=0X8oumNj9kc video link]




{{GameCategory|arma3|Editing}}
{{GameCategory|arma3|Editing}}
{{GameCategory|arma3| Tutorials}}
{{GameCategory|arma3|Tutorials}}

Revision as of 11:31, 18 February 2022

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 location

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:

_animal setVariable ["BIS_fnc_animalBehaviour_disable", true];


Animations

Animations can be played using playMove, playMoveNow or switchMove. Their names are quite self-explanatory.

Animals will remain in the same animation cycle until manually changed!

Dog

_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

  • "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"
↑ Back to spoiler's top

Sheep

_sheep playMove "Sheep_Stop";
_sheep playMove "Sheep_Walk";
_sheep playMove "Sheep_Run";
_sheep playMove "Sheep_Idle_Stop"; // wandering, default behaviour

Goat

_goat playMove "Goat_Stop";
_goat playMove "Goat_Walk";
_goat playMove "Goat_Run";
_goat playMove "Goat_Idle_Stop"; // wandering, default behaviour

Rabbit

_rabbit playMove "Rabbit_Stop";
_rabbit playMove "Rabbit_Hop";
_rabbit playMove "Rabbit_Idle_Stop"; // wandering, default behaviour

Cockerel

_cock playMove "Cock_Stop";
_cock playMove "Cock_Walk";
_cock playMove "Cock_Run";
_cock playMove "Cock_Idle_Stop"; // wandering, default behaviour

Hen

_hen playMove "Hen_Stop";
_hen playMove "Hen_Walk";
_hen playMove "Hen_Idle_Stop"; // wandering, default behaviour

Snake

_snake playMove "Snakes_Stop";
_snake playMove "Snakes_Move";
_snake playMove "Snakes_Idle_Stop"; // wandering, default behaviour


Examples

Script

Simple example for a dog to follow the player:

// 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 1; alive _dog } do
	{
		_dog moveTo getPosATL player;
	};
};

Mission