Polarith AI
1.8
AIMFormationConfiguration Class Reference

Description

Assigns the agents to their position inside the formation.

Also calls the low-level logic to compute the agents' position inside the formation. Optionally, the agents are gathered from the child objects automatically.

You may want to provide your own assignment logic. Therefore, you need to inherit from AIMFormationConfiguration, and provide an assignment method that as in Polarith.UnityUtils.AssignmentSolver. You should make yourself familiar with the so called assignment problem. Our simple assignment method Polarith.UnityUtils.AssignmentSolver.FindGreedy(List<AIMFormation>, List<Vector3>, int) is a serialized greedy algorithm, the complex method Polarith.UnityUtils.AssignmentSolver.FindOptimal(int[,]) implements the so-called Hungarian Method.

Inheritance diagram for AIMFormationConfiguration:

Protected Fields

List< AIMFormationagents = new List<AIMFormation>()
 AIMFollow behaviours of the agents. More...
 
bool assignOnStart = true
 Toggle if the assignment should be performed on start. More...
 
bool autoObtainChildren = true
 Toggle if agents should be assigned automatically to the agents list. More...
 
bool autoObtainSize = true
 Toggle if the maximum number of agents in the formation should be adjusted to the actual number of agents automatically. More...
 
GameObject foreignObtainment
 If a foreign game object is set, the auto options are applied on that game object. More...
 
float assignComplexity = 0.5f
 You can select the complexity of the assignment algorithm. More...
 
List< Vector3 > targetPositions = new List<Vector3>()
 List of the target positions obtained by the agents, i.e., the target positions in the formation. More...
 

Properties

List< AIMFormationAgents [get, set]
 AIMFollow behaviours of the agents. More...
 
bool AssignOnStart [get, set]
 Toggle if the assignment should be performed on start. More...
 
bool AutoObtainChildren [get, set]
 Toggle if agents should be assigned automatically to the agents list. More...
 
bool AutoObtainSize [get, set]
 Toggle if the maximum number of agents in the formation should be adjusted to the actual number of agents automatically. More...
 
GameObject ForeignObtainment [get, set]
 If a foreign game object is set, the auto options are applied on that game object. More...
 
float AssignComplexity [get, set]
 You can select the complexity of the assignment algorithm. More...
 

Public Methods

virtual void Assignment (int size)
 Virtual method to assign the agents to the target positions. More...
 
virtual void UpdateConfig ()
 Updates the list of Agents if AutoObtainChildren is enabled, updates the Formation.Size if AutoObtainSize is enabled, recomputes the assignments, and updates the behaviours of the agents with the new assignments. More...
 

Protected Methods

virtual void AutoObtainAgents ()
 Looks for AIMFormation instances in the child objects recursively, and adds them to the Agents list. More...
 
virtual int GetFormationSize ()
 Get the number of active agents that are child objects of the AIMFormationConfiguration. More...
 
void SetupBehaviours (int[] assigns)
 Sets the target position in Formation for each agent in Agents. More...
 
Imprint