A* Pathfinding Project
4.2.5
The A* Pathfinding Project for Unity 3D
|
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 around the bounds of the collider on the same GameObject.
This script works with both 2D colliders and normal 3D colliders.
Public Member Functions | |
void | DoUpdateGraphs () |
Update the graphs around this object. More... | |
override void | OnPostScan () |
Called right after all graphs have been scanned. More... | |
Public Member Functions inherited from GraphModifier | |
virtual void | OnGraphsPostUpdate () |
Called after graphs have been updated using GraphUpdateObjects. More... | |
virtual void | OnGraphsPreUpdate () |
Called before graphs are updated using GraphUpdateObjects. More... | |
virtual void | OnLatePostScan () |
Called at the end of the scanning procedure. More... | |
virtual void | OnPostCacheLoad () |
Called after cached graphs have been loaded. More... | |
virtual void | OnPreScan () |
Called right before graphs are going to be scanned. More... | |
Public Attributes | |
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... | |
Protected Member Functions | |
override void | Awake () |
override void | OnDisable () |
Revert graphs when disabled. More... | |
Protected Member Functions inherited from GraphModifier | |
virtual void | OnDestroy () |
virtual void | OnEnable () |
Adds this modifier to list of active modifiers. More... | |
override void | Reset () |
Handle serialization backwards compatibility. More... | |
Protected Member Functions inherited from VersionedMonoBehaviour | |
virtual int | OnUpgradeSerializedData (int version, bool unityThread) |
Handle serialization backwards compatibility. More... | |
Properties | |
Bounds | bounds [get] |
bool | colliderEnabled [get] |
Private Member Functions | |
void | Update () |
Static Private Member Functions | |
static float | BoundsVolume (Bounds b) |
Volume of a Bounds object. More... | |
Private Attributes | |
Collider | coll |
Collider to get bounds information from. More... | |
Collider2D | coll2D |
2D Collider to get bounds information from More... | |
float | lastCheckTime = -9999 |
Bounds | prevBounds |
Bounds of the collider the last time the graphs were updated. More... | |
bool | prevEnabled |
True if the collider was enabled last time the graphs were updated. More... | |
Quaternion | prevRotation |
Rotation of the collider the last time the graphs were updated. More... | |
Transform | tr |
Cached transform component. More... | |
Additional Inherited Members | |
Public Types inherited from GraphModifier | |
enum | EventType { PostScan = 1 << 0, PreScan = 1 << 1, LatePostScan = 1 << 2, PreUpdate = 1 << 3, PostUpdate = 1 << 4, PostCacheLoad = 1 << 5 } |
GraphModifier event type. More... | |
Static Public Member Functions inherited from GraphModifier | |
static void | FindAllModifiers () |
static void | TriggerEvent (GraphModifier.EventType type) |
Triggers an event for all active graph modifiers. More... | |
Static Protected Member Functions inherited from GraphModifier | |
static List< T > | GetModifiersOfType< T > () |
Protected Attributes inherited from GraphModifier | |
ulong | uniqueID |
Unique persistent ID for this component, used for serialization. More... | |
Static Protected Attributes inherited from GraphModifier | |
static Dictionary< ulong, GraphModifier > | usedIDs = new Dictionary<ulong, GraphModifier>() |
Maps persistent IDs to the component that uses it. More... | |
|
protectedvirtual |
Reimplemented from GraphModifier.
|
staticprivate |
Volume of a Bounds object.
X*Y*Z
void DoUpdateGraphs | ( | ) |
Update the graphs around this object.
|
protectedvirtual |
Revert graphs when disabled.
When the DynamicObstacle is disabled or destroyed, a last graph update should be done to revert nodes to their original state
Reimplemented from GraphModifier.
|
virtual |
Called right after all graphs have been scanned.
FloodFill and other post processing has not been done.
Reimplemented from GraphModifier.
|
private |
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 extra unnecessary graph updates.
In real time seconds (based on Time.realtimeSinceStartup).
|
private |
Collider to get bounds information from.
|
private |
2D Collider to get bounds information from
|
private |
|
private |
Bounds of the collider the last time the graphs were updated.
|
private |
True if the collider was enabled last time the graphs were updated.
|
private |
Rotation of the collider the last time the graphs were updated.
|
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.
|
getprivate |
|
getprivate |