NavMeshObstacle
An obstacle for NavMeshAgents to avoid.
Read time 7 minutesLast updated 8 days ago
Definition
- Type: Class
- Namespace: UnityEngine.AI
- Assembly: UnityEngine.AIModule
- Inherits from: Behaviour
[HelpURL("https://docs.unity3d.com/Packages/com.unity.ai.navigation@2.0/manual/NavMeshObstacle.html")]public sealed class NavMeshObstacle : Behaviour
Remarks
A NavMeshObstacle is cylindrical in shape and can move around the surface of the NavMesh with a specified velocity. By default, the obstacle will only affect the agent's avoidance behaviour rather than the pathfinding. This means that the agent will ignore the obstacle when plotting a path but will sidestep around it while moving along the path. If carving is enabled, the obstacle will create a temporary "hole" in the NavMesh. The hole will be recognised by the pathfinding, so paths will be plotted to avoid the obstacle. This means that if, say, an obstacle blocks a narrow gap, the pathfinding will seek an alternative route to the target. Without carving, the agent will head for the gap but won't be able to pass until the obstacle is clear.
Additional Resources: NavMeshAgent.
Properties
Property | Description |
|---|---|
| carveOnlyStationary | Should this obstacle be carved when it is constantly moving? |
| carving | Should this obstacle make a cut-out in the navmesh. |
| carvingMoveThreshold | Threshold distance for updating a moving carved hole (when carving is enabled). |
| carvingTimeToStationary | Time to wait until obstacle is treated as stationary (when carving and carveOnlyStationary are enabled). |
| center | The center of the obstacle, measured in the object's local space. |
| height | Height of the obstacle's cylinder shape. |
| radius | Radius of the obstacle's capsule shape. |
| shape | The shape of the obstacle. |
| size | The size of the obstacle, measured in the object's local space. |
| velocity | Velocity at which the obstacle moves around the NavMesh. |
Inheritance
Operators
Operator | Description |
|---|---|
| operator == | Compares two object references to see if they refer to the same object. |
| bool | Determines whether the object exists. |
| operator != | Compares if two objects refer to a different object. |