Attach this script to any obstacle with a collider to enable dynamic updates of the graphs around it.
More...
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
|
float | checkTime = 0.2F |
| Time in seconds between bounding box checks. More...
|
|
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. More...
|
|
◆ Awake()
◆ BoundsVolume()
static float BoundsVolume |
( |
Bounds |
b | ) |
|
|
staticprivate |
Volume of a Bounds object.
X*Y*Z
◆ DoUpdateGraphs()
Update the graphs around this object.
- Note
- The graphs will not be updated immediately since the pathfinding threads need to be paused first. If you want to guarantee that the graphs have been updated then call AstarPath.active.FlushGraphUpdates() after the call to this method.
◆ OnDestroy()
override void OnDestroy |
( |
| ) |
|
|
protectedvirtual |
Revert graphs when destroyed.
When the DynamicObstacle is destroyed, a last graph update should be done to revert nodes to their original state
Reimplemented from GraphModifier.
◆ OnPostScan()
override void OnPostScan |
( |
| ) |
|
|
virtual |
Called right after all graphs have been scanned.
FloodFill and other post processing has not been done.
- Warning
- Since OnEnable and Awake are called roughly in the same time, the only way to ensure that these scripts get this call when scanning in Awake is to set the Script Execution Order for AstarPath to some time later than default time (see Edit -> Project Settings -> Script Execution Order).
- Todo:
- Is this still relevant? A call to FindAllModifiers should have before this method is called so the above warning is probably not relevant anymore.
- See also
- OnLatePostScan
Reimplemented from GraphModifier.
◆ Update()
◆ checkTime
◆ coll
Collider to get bounds information from.
◆ lastCheckTime
float lastCheckTime = -9999 |
|
private |
◆ prevBounds
Bounds of the collider the last time the graphs were updated.
◆ prevEnabled
True if the collider was enabled last time the graphs were updated.
◆ prevRotation
Rotation of the collider the last time the graphs were updated.
◆ tr
Cached transform component.
◆ updateError
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:
- /Users/arong/Unity/a-pathfinding-project/Assets/AstarPathfindingProject/ExampleScenes/ExampleScripts/DynamicGridObstacle.cs