Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
NavigationObstacle2D
實驗性: This class may be changed or removed in future versions.
繼承: Node2D < CanvasItem < Node < Object
2D obstacle used to affect navigation mesh baking or constrain velocities of avoidance controlled agents.
說明
An obstacle needs a navigation map and outline vertices defined to work correctly. The outlines can not cross or overlap.
Obstacles can be included in the navigation mesh baking process when affect_navigation_mesh is enabled. They do not add walkable geometry, instead their role is to discard other source geometry inside the shape. This can be used to prevent navigation mesh from appearing in unwanted places. If carve_navigation_mesh is enabled the baked shape will not be affected by offsets of the navigation mesh baking, e.g. the agent radius.
With avoidance_enabled the obstacle can constrain the avoidance velocities of avoidance using agents. If the obstacle's vertices are wound in clockwise order, avoidance agents will be pushed in by the obstacle, otherwise, avoidance agents will be pushed out. Obstacles using vertices and avoidance can warp to a new position but should not be moved every single frame as each change requires a rebuild of the avoidance map.
教學
屬性
|
||
|
||
|
||
|
||
|
||
|
||
|
方法
get_avoidance_layer_value(layer_number: int) const |
|
get_navigation_map() const |
|
get_rid() const |
|
void |
set_avoidance_layer_value(layer_number: int, value: bool) |
void |
set_navigation_map(navigation_map: RID) |
屬性說明
bool affect_navigation_mesh = false 🔗
If enabled and parsed in a navigation mesh baking process the obstacle will discard source geometry inside its vertices defined shape.
bool avoidance_enabled = true 🔗
如果為 true,則該障礙物會影響使用代理的避障。
決定該障礙物的避障層的位域。避障遮罩中存在配對位元的代理會躲避該障礙物。
bool carve_navigation_mesh = false 🔗
If enabled the obstacle vertices will carve into the baked navigation mesh with the shape unaffected by additional offsets (e.g. agent radius).
It will still be affected by further postprocessing of the baking process, like edge and polygon simplification.
Requires affect_navigation_mesh to be enabled.
設定該障礙物的避障半徑。
Vector2 velocity = Vector2(0, 0) 🔗
設定該障礙物的期望速度,這樣如果(每影格)一直使用相同的速度移動而不是直接跳到某個位置,那麼其他代理就能夠更好地預測該障礙物的行為。僅影響該障礙物 radius 的避障。不會影響障礙物的靜態頂點。
PackedVector2Array vertices = PackedVector2Array() 🔗
void set_vertices(value: PackedVector2Array)
PackedVector2Array get_vertices()
該障礙物的輪廓頂點。如果這些頂點是按照順時針順序纏繞的,那麼障礙物就會將其他代理向內推,否則就會向外推。輪廓不能交叉或重疊。如果這些頂點直接跳到了新的位置,那麼其他代理可能無法預測這種行為,導致被困在障礙物內。
Note: The returned array is copied and any changes to it will not update the original property value. See PackedVector2Array for more details.
方法說明
bool get_avoidance_layer_value(layer_number: int) const 🔗
返回 avoidance_layers 位元遮罩中指定的層是否啟用,給定的 layer_number 應在 1 和 32 之間。
RID get_navigation_map() const 🔗
返回該 NavigationObstacle 節點的導覽地圖的 RID。該函式始終返回在 NavigationObstacle 節點上設定的地圖,而不是 NavigationServer 上抽象障礙物所使用的地圖。如果該障礙物地圖使用 NavigationServer API 直接更改,則該 NavigationObstacle 節點將不會察覺該地圖的更改。請使用 set_navigation_map() 更改 NavigationObstacle 的導覽地圖,也會更新 NavigationServer 上的障礙物。
返回這個障礙物在 NavigationServer2D 上的 RID。
void set_avoidance_layer_value(layer_number: int, value: bool) 🔗
根據 value 啟用或禁用 avoidance_layers 位元遮罩中指定的層,給定的 layer_number 應在 1 和 32 之間。
void set_navigation_map(navigation_map: RID) 🔗
設定該 NavigationObstacle 節點應使用的導覽地圖的 RID,並會更新 NavigationServer 上的 obstacle。