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:
- Add
TeamAuthoringto the entities. - Add
VisionSourceAuthoringto units that should provide vision for that team. - Add
VisibilitySwitchAuthoringto units or objects that should report who sees them. - In your AI systems, read
VisibilityStateand callIsDetectedByTeam(...).