Skip to content

Alaa-AbuSarah/FieldOfView

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FieldOfView Script

Overview The FieldOfView script in this repository is designed to create a field of view for detecting objects within a specified radius and angle. It's particularly useful for implementing vision or detection systems in Unity projects.

FOVFOV flow

Features

  • Field Parameters: Allows customization of the field's radius, angle, and offset from the origin.
  • Target and Obstruction Masks: Specify the layers to be considered as targets and obstructions for detection.
  • Field Method: Includes a method Field<T>(string tag = null) that returns a list of objects of a specified type (T) within the defined field of view based on certain conditions.

Usage

  1. Attach the Script: Attach the FieldOfView.cs script to a GameObject in your Unity scene.
  2. Set Parameters: Adjust the radius, angle, offset, and layer masks in the Inspector according to your requirements.
  3. Call the Field Method: Use the Field<T>(string tag = null) method to retrieve a list of objects within the defined field of view.

Example Usage:

// Example usage in another script
List<YourObjectType> detectedObjects = GetComponent<FieldOfView>().Field<YourObjectType>("YourTag");
// Replace YourObjectType with the actual type of object you're looking for and "YourTag" with the specific tag condition (or leave it null to ignore tag conditions).

Notes

  • Ensure the necessary colliders and tags are appropriately set up on the objects you want to detect within the field of view.
  • Make sure to handle the visibility checks and responses to detected objects as per your game or application requirements.