ProximityTracker
This script tracks objects that are near the object to which the script is attached. The script is configured to track in a 2d scene by default. It uses SphereCast to determine what objects are near.
Contents |
Public Variables
radius : float
This determines how big the sphere that is cast is, and therefore how close things must be to be within the cast distance.
updateInterval : float
How often to update the tracking list, in seconds.
sphereCastDirection : Vector3
This is the direction that the sphere cast will be sent.
sphereCastRelativeStartingPosition : Vector3
This is the relative position of where the sphere cast that checks for objects around the current object will start.
sphereCastDistance : float
How far to send the sphere cast when tracking.
layersToTrack : LayerMask
This allows only objects on certain layers to be tracked.
Public Functions
GameObject GetClosest ()
Returns the object that is closest to the object to which the script is attached. This returns null if no objects are within range.
List<GameObject> GetAll ()
Returns the list of all objects that are within tracking range of the object to which the script is attached.