Polarith AI
1.8
Vector Projection

AI systems typically do not perceive the same visual representation like the user/player of your application does, because everything the player sees is not necessarily relevant for an AI agent. Currently, our AI system only supports planar sensor shapes. Hence, game scenarios like flight or space simulations are not completely supported yet (but planned for future releases via a new sensor type). However, planar-shaped sensors are also suitable for common 3D scenarios where some kind of ground is present, for example, a terrain.

The purpose of the VectorProjection is to project object/percept data into the same plane as the agent moves in, like its illustrated in Figure 1 below. This way, it is easier to handle the configuration of behaviours and sometimes it is even necessary to do so.

Figure 1: Shows the concept of VectorProjection.

Example

The following abstract example explains why VectorProjection is important and how you use it right.

Imagine a simple 2D shoot 'em up where everything is represented by sprites: The player, enemies, bullets, obstacles, and back-/foreground objects. To organize your scene and manage occlusion, you would assign different Z-values for the objects (the default plane for 2D games in Unity is XY). For example, foreground objects get a 0, bullets get a 2 and enemies respectively the player a 4 and so forth. Now, you want to create some intelligent enemies which dodge bullets and obstacles. The receptors of the sensors are located in the XY plane at a Z-value of 4. However, other objects such as bullets and obstacles have different Z-values. Without projection the resulting magnitudes would be a bit off. For example, given a receptor with Direction = (0, 1, 0), you would expect to get a magnitude of 1 when a percept lies in the exact same direction. The problem now is that an obstacle, for instance, with a different Z-value than the agent would cause a ResultDirection like, e.g., (0, 0.83, 0.55). So the resulting magnitude would be smaller than 1. This can be resolved by using VectorProjection, which is advised for such a scenario. By projecting the direction of the percept into the plane of the agent, it would be (0, 1, 0) as expected, no matter what Z-values are assigned.

Remarks

We highly recommend to make use of the VectorProjection even for 3D scenarios having a terrain. The height or slope information can be included in different ways instead. For example, the terrain slope is implicitly included when using our Seek NavMesh behaviour since Unity's NavMesh already excludes areas where the terrain is too steep.

Imprint