Class DynamicObstacle Extends GraphModifier, DynamicGridObstacle

Public

Updates graphs around the object as it moves.

Attach this script to any obstacle with a collider to enable dynamic updates of the graphs around it. When the object has moved or rotated at least updateError world units then it will call AstarPath.UpdateGraphs to 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 DynamicObstacle component is attached to since this script only updates the graph around the bounds of the collider on the same GameObject.

An update will be triggered whenever the bounding box of the attached collider has changed (moved/expanded/etc.) by at least updateError world units or if the GameObject has rotated enough so that the outmost point of the object has moved at least updateError world units.

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

Note

This script works with a GridGraph, PointGraph, LayerGridGraph or RecastGraph. However, for recast graphs, you can often use the NavmeshCut instead, for simple obstacles. The NavmeshCut can be faster, but it's not quite as flexible.

Public Methods

Update the graphs around this object.

Called right after all graphs have been scanned.

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

Called after graphs have been updated using GraphUpdateObjects or navmesh cutting.

Called after graphs have been updated.

Called before graphs are updated using GraphUpdateObjects.

Called at the end of the scanning procedure.

Called after cached graphs have been loaded.

Called after a graph has been deserialized and loaded.

Called right before graphs are going to be scanned.

TriggerEvent (type)

Triggers an event for all active graph modifiers.

Private/Protected Members

Awake ()

Volume of a Bounds object.

Revert graphs when disabled.

Adds this modifier to list of active modifiers.

OnUpgradeSerializedData (migrations, unityThread)

Handle serialization backwards compatibility.

Reset ()

Handle serialization backwards compatibility.

Update ()
UpgradeSerializedData (isUnityThread)
bounds
Private
checkTime
Private
coll

Collider to get bounds information from.

Private
coll2D

2D Collider to get bounds information from

Private
colliderEnabled
Private
lastCheckTime
Private
pendingGraphUpdates
Private
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
tr

Cached transform component.

Private
uniqueID

Unique persistent ID for this component, used for serialization.

Protected
updateError
Private
usedIDs

Maps persistent IDs to the component that uses it.

Protected Static