NavMeshObstacle 导航网格障碍

class in UnityEngine/Inherits from: Behaviour

Description 描述

An obstacle for NavMeshAgents to avoid.


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.

导航网格障碍是圆柱形的并且可以用指定速度围绕导航网格表面移动。在默认情况下,障碍仅影响代理的躲避行为而不是寻路。这意味着当测绘路径时代理将会忽略该障碍,但是沿着路径移动时代理将会在障碍的附近回避。如果启用carving ,障碍将会在导航网格上创建一个临时的“突破口”。该突破口将会被寻路认可,因此测绘路径时将会避免该障碍。这意味着如果说障碍阻塞缺口,寻路将会寻找一个替代路线给目标。没有启用carving,代理将会朝缺口前进但是不可能通过缺口直到该障碍被清除。

Variables 变量

carveOnlyStationaryShould this obstacle be carved when it is constantly moving?
carvingShould this obstacle make a cut-out in the navmesh.
carvingMoveThresholdThreshold distance for updating a moving carved hole (when carving is enabled).
carvingTimeToStationaryTime to wait until obstacle is treated as stationary (when carving and carveOnlyStationary are enabled).
centerThe center of the obstacle, measured in the object's local space.
heightHeight of the obstacle's cylinder shape.
radiusRadius of the obstacle's capsule shape.
shapeShape of the obstacle.
sizeThe size of the obstacle, measured in the object's local space.
velocityVelocity at which the obstacle moves around the NavMesh.