front-end: AIMLodGroup
Similar to level-of-detail (LOD) systems well-known from computer graphics (CG), the Lod Group is a great way for optimizing the performance of your AI system. Such flexibility at adapting the agents' precision is a novelty in the field of steering AI. The idea is as simple as effective, define a center as reference and a set of distance-sensor pairs. The component then manages the sensor which is assigned to the agent's Context by switching it with respect to the currently matching distance-sensor pair. Since replacing the sensor is similar to switching a reference, there is no noticeable performance impact at runtime for accomplishing the exchange.
This component has got the following specific properties.
Property | Description |
---|---|
Center | The reference point of the level-of-detail system. All given distances refer to this point. If it is empty, the component searches for a game object using the CenterTag . If nothing is found, the Lod Group is disabled. |
CenterTag | This tag is used if the Center is empty. OnEnable , the component tries to find an object specified by this tag. Per default, the component searches for the MainCamera tag. |
UpdateFrequency | Specifies how often this component is updated. In most cases, a value greater than 0 can be used to avoid unnecessary distance checks in every update step. If it is set to 0, the component updates itself as often as possible. |
DeactivateOnLast | If this property is checked, the Context component of the agent is disabled when its distance is greater than the last possible LOD distance. When the distance is smaller, the Context component is enabled. This information can be used by your components (e.g. your character controller) to deactivate the agent or other sub-systems for saving performance. |
LodList | A collection containing the distance-sensor pairs. The elements are in ascending order. Hence, everything within the range of Lod 0 uses the sensor corresponding sensor for Lod 0. The Lod 1 sensor is used in the range between Lod 0 and the distance of Lod 1 and so forth. Thus, the sensor with a fine resolution should be used in Lod 0 and the coarsest sensor should be used in the last distance-sensor pair (see preview down below). |
In the UI, as can bee seen at the top of this page, there is always one more sensor than there are distances. This sensor is the default sensor that is used if no LOD distance matches. The last LOD distance defines the maximum value for the other LOD distances. Hence, it is a good workflow to define the distances beginning from the last element up to the first element.
For LOD system known from CG, it is common to use the view frustum for culling unnecessary objects to avoid rendering. However, this is not feasible for our case because an agent has to work independently of the players view direction in general. As long as it is near by, it should behave as precise as possible, even when you do not look at it (possible team mates, bots and so forth). Thus, distances imply spheres around the Center
point.