Top-down AI sensor 2D
This is standalone version of my "Top-down Ai sensor 2D" that is included inside my utils package, so it doesn't require any additional imports to work properly.
Overview
Presented tool is an Ai sensor that is intended to be used in 2D top-down perspective environmewnts. It contains its own custom editor to display all the modifiable parameters and the GUI to visualize character's field of view.
How it works
System performs cyclical operations by checking if selected target can be spotted by the character.
Spot check:
- check the distance between target and character
- check if the target is inside character's field of view
- check if the target is not behind any obstacle
Setup
- attach "TopDownAiSensor2D" component to game object:
- adjust values inside inspector to suit your needs
- set target object via uinspector or inside "Awake" method
private void Awake()
{
if (targetObject == null)
{
// set target object here
targetObject = GameObject.FindGameObjectWithTag("Player");
}
}