A* Pathfinding Project  3.8.2
The A* Pathfinding Project for Unity 3D
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Events Macros Groups Pages
DynamicGridObstacle Class Reference

Attach this script to any obstacle with a collider to enable dynamic updates of the graphs around it. More...

Detailed Description

Attach this script to any obstacle with a collider to enable dynamic updates of the graphs around it.

When the object has moved a certain distance (or actually when it's bounding box has changed by a certain amount) defined by updateError it will call AstarPath.UpdateGraphs and update the graph around it.

Make sure that any children colliders do not extend beyond the bounds of the collider attached to the GameObject that the DynamicGridObstacle component is attached to since this script only updates the graph using the bounds of the collider on the same GameObject.

Note
This script only works with GridGraph, PointGraph and LayerGridGraph
See Also
AstarPath.UpdateGraphs
graph-updates

Public Member Functions

void DoUpdateGraphs ()
 

Public Attributes

float checkTime = 0.2F
 Time in seconds between bounding box checks.
 
float updateError = 1
 The minimum change in world units along one of the axis of the bounding box of the collider to trigger a graph update.
 

Private Member Functions

void OnDestroy ()
 Revert graphs when destroyed.
 
void Start ()
 
void Update ()
 

Static Private Member Functions

static float BoundsVolume (Bounds b)
 Returns the volume of a Bounds object.
 

Private Attributes

Collider col
 Collider to get bounds information from.
 
float lastCheckTime = -9999
 
Bounds prevBounds
 Bounds of the collider the last time the graphs were updated.
 
bool prevEnabled
 True if the collider was enabled last time the graphs were updated.
 
Quaternion prevRotation
 Rotation of the collider the last time the graphs were updated.
 
Transform tr
 Cached transform component.
 

Member Function Documentation

static float BoundsVolume ( Bounds  b)
staticprivate

Returns the volume of a Bounds object.

X*Y*Z

void DoUpdateGraphs ( )
void OnDestroy ( )
private

Revert graphs when destroyed.

When the DynamicObstacle is destroyed, a last graph update should be done to revert nodes to their original state

void Start ( )
private
void Update ( )
private

Member Data Documentation

float checkTime = 0.2F

Time in seconds between bounding box checks.

If AstarPath.batchGraphUpdates is enabled, it is not beneficial to have a checkTime much lower than AstarPath.graphUpdateBatchingInterval because that will just add unnecessary many graph updates.

Collider col
private

Collider to get bounds information from.

float lastCheckTime = -9999
private
Bounds prevBounds
private

Bounds of the collider the last time the graphs were updated.

bool prevEnabled
private

True if the collider was enabled last time the graphs were updated.

Quaternion prevRotation
private

Rotation of the collider the last time the graphs were updated.

Transform tr
private

Cached transform component.

float updateError = 1

The minimum change in world units along one of the axis of the bounding box of the collider to trigger a graph update.


The documentation for this class was generated from the following file: