Skip to content

AI Vision Integration

VisionSource on AI units

Adding VisionSourceAuthoring to computer controlled units is optional.

You only need to do it if you want those teams to have their own vision and if you want to integrate that vision with AI behavior.

Without VisionSourceAuthoring, those units do not contribute any team vision data.

VisibilitySwitch on player units

Adding VisibilitySwitchAuthoring to player units is also optional.

By default, this setup is mainly used to show or hide enemies depending on whether the player can see them.

But if you want to know whether enemy teams can see the player, then player units also need VisibilitySwitchAuthoring.

That is what makes the system write detection data for them into VisibilityState.

How to use it in AI

If you want to integrate your own AI with vision, read VisibilityState and call IsDetectedByTeam(Team team).

Example:

bool seesPlayer = visibilityState.IsDetectedByTeam(Team.Computer1);

Typical setup

If you want AI teams to use vision:

  1. Add TeamAuthoring to the entities.
  2. Add VisionSourceAuthoring to units that should provide vision for that team.
  3. Add VisibilitySwitchAuthoring to units or objects that should report who sees them.
  4. In your AI systems, read VisibilityState and call IsDetectedByTeam(...).