front-end: AIMFormationConfiguration
Source code available on GitHub.
Hence the Formation
behaviours are decentralized, the configuration of them is quite cumbersome since the Size and Position in Formation must be set manually. Additionally, a visually nice assignment between the agents and the positions comes down to the so-called Assignment Problem. Therefore, we implemented the handy AIMFormationConfiguration. This little helper allows you to gather and assign the agents automatically.
The Agents list can be used to select the agents manually. To start the assignment on the start, set AssignOnStart
to true. If you want to gather the formation agents automatically, you need set Auto Obtain Children
to true to attach them as child objects to the game object containing AIMFormationConfiguration. It doesn't matter, whether the Formation component is nested in a child object, or is directly attached. The first active Formation component in each child will be added to the Agents
list as long as the list's size is not exceeded or AutoObtainSize
is true. If you want to use the automatic selection for Agents
but don't want to use AutoObtainSize
, you can set the size manually. This might be useful if some agents are deactivated child objects. Note that AutoObtainSize
counts ALL attached child objects, even if they are deactivated or do not contain a Formation component. This size is set in Formation.Size.
Until now, we have configured child objects, but sometimes it is useful to encapsulate the configuration head from the agents, e.g. for a formation of formations as shown in the package. Therefore, you need to attach the new parent game object 'ForeignObtainment'. The options selected in AIMFormationConfiguration are now performed on the foreign game object.
As pointed out in the Manual, we provide two different logics to solve the Assignment Problem in the background using our AssignmentSolver. You can interpolate between these two logics using the AssignComplexity
. A value of 0 means non-optimal but fast, while 1 means optimal but slow. Feel free to test the performance impact on your system.
This component has got the following specific properties.
Property | Description |
---|---|
Agents | The list of agents that should be configured. |
AssignOnStart | Toggles if the assignment should be performed on startup. Otherwise, you need to call UpdateConfig(). |
AutoObtainChildren | Toggles if the agents with a Formation component are gathered automatically. Note that the game objects must be child objects. |
AutoObtainSize | Toggles if the size of Agents and Formation.Size should be set automatically. Note that all direct child objects are counted, even if they are deactivated or do not contain a Formation component. |
ForeignObtainment | If not null, the attached game object is used to perform the configuration steps instead of the current game object that has the configuration script attached. |
AssignComplexity | A value to interpolate between both assignment algorithms. 0 means non-optimal, but fast, 1 means optimal, but slow. |
Building of a solid planar box formation. Left: AssignComplexity
= 0. Right: AssignComplexity
= 1.
If you want to re-assign the agents during runtime, you need to call UpdateConfig(). This method re-assigns the agents with the options selected via the properties.
This component consists of different virtual methods. This way, you can re-write the core logic or only minor parts.