Class DynamicGridObstacle Extends GraphModifier

Public

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 around the bounds of the collider on the same GameObject.

This script works with both 2D colliders and normal 3D colliders.

Note

This script only works with GridGraph, PointGraph and LayerGridGraph

See

AstarPath.UpdateGraphs

graph-updates

Public Methods

DoUpdateGraphs ()

Update the graphs around this object.

Public
OnPostScan ()

Called right after all graphs have been scanned.

Public

Public Variables

checkTime

Time in seconds between bounding box checks.

Public
updateError

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

Public

Inherited Public Members

EventType

GraphModifier event type.

Public
FindAllModifiers ()
Public Static
OnGraphsPostUpdate ()

Called after graphs have been updated using GraphUpdateObjects.

Public
OnGraphsPreUpdate ()

Called before graphs are updated using GraphUpdateObjects.

Public
OnLatePostScan ()

Called at the end of the scanning procedure.

Public
OnPostCacheLoad ()

Called after cached graphs have been loaded.

Public
OnPreScan ()

Called right before graphs are going to be scanned.

Public
TriggerEvent (type)

Triggers an event for all active graph modifiers.

Public Static

Private/Protected Members

Awake ()
Protected
bounds
Private
BoundsVolume (b)

Volume of a Bounds object.

Private Static
coll

Collider to get bounds information from.

Private
coll2D

2D Collider to get bounds information from

Private
colliderEnabled
Private
GetModifiersOfType< T > ()
Protected Static
lastCheckTime
Private
OnDestroy ()
Protected
OnDisable ()

Revert graphs when disabled.

Protected
OnEnable ()

Adds this modifier to list of active modifiers.

Protected
OnUpgradeSerializedData (version, unityThread)

Handle serialization backwards compatibility.

Protected
prevBounds

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

Private
prevEnabled

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

Private
prevRotation

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

Private
Reset ()

Handle serialization backwards compatibility.

Protected
tr

Cached transform component.

Private
uniqueID

Unique persistent ID for this component, used for serialization.

Protected
Update ()
Private
usedIDs

Maps persistent IDs to the component that uses it.

Protected Static