Animals: Override Default Animal Behaviour Via Script – Arma 3

From Bohemia Interactive Community
Jump to navigation Jump to search


Template:note


Introduction

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.

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.

Basics

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.

Module Animals from Sites category

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.

Spawn via createAgent command

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! 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 agents can be controlled via moveTo command. And you can also determine, in which state (like run, sprint, etc.) the animal will move.

Example:

_dog = createAgent ["Fin_random_F", getPos player, [], 5, "CAN_COLLIDE"];

Spawn via createUnit command

Template:note

Another way to spawn animal is using createUnit command. 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. You can additionally command the animal via doMove and doStop commands, so you will be able to control it.

Example:

_grp = createGroup CIVILIAN;
_dog = _grp createUnit ["Fin_random_F", getPos player, [], 5, "CAN_COLLIDE"];

Additionaly the animal can be groupped with player and thus will be able to obey some basic commands like Move via command menu.

Example:

_dog = group player createUnit ["Fin_random_F", getPos player, [], 5, "CAN_COLLIDE"];

Usage

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 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_disable variable!

Example mission for VR map

You can try this mission - simply download ZIP archive with it here. All dog actions are controllable via action menu. See this video captured from this example mission.

Currently available animals

Dog

Available states

Stop:

_dog playMove "Dog_Stop";

Sit:

_dog playMove "Dog_Sit";

Walk:

_dog playMove "Dog_Walk";

Run:

_dog playMove "Dog_Run";

Sprint:

_dog playMove "Dog_Sprint";

Back to default behaviour:

_dog playMove "Dog_Idle_Stop";

Sheep

Stop:

_sheep playMove "Sheep_Stop";

Walk:

_sheep playMove "Sheep_Walk";

Run:

_sheep playMove "Sheep_Run";

Back to default behaviour:

_sheep playMove "Sheep_Idle_Stop";

Goat

Stop:

_goat playMove "Goat_Stop";

Walk:

_goat playMove "Goat_Walk";

Run:

_goat playMove "Goat_Run";

Back to default behaviour:

_goat playMove "Goat_Idle_Stop";

Rabbit

Stop:

_rabbit playMove "Rabbit_Stop";

Hop:

_rabbit playMove "Rabbit_Hop";

Back to default behaviour:

_rabbit playMove "Rabbit_Idle_Stop";

Cockerel

Stop:

_cock playMove "Cock_Stop";

Walk:

_cock playMove "Cock_Walk";

Run:

_cock playMove "Cock_Run";

Back to default behaviour:

_cock playMove "Cock_Idle_Stop";