NavigationObstacle3D
3D obstacle used to affect navigation mesh baking or constrain velocities of avoidance controlled agents.
3D obstacle used to affect navigation mesh baking or constrain velocities of avoidance controlled agents.
An obstacle needs a navigation map and outline NavigationObstacle3D.Vertices defined to work correctly. The outlines can not cross or overlap and are restricted to a plane projection. This means the y-axis of the vertices is ignored, instead the obstacle's global y-axis position is used for placement. The projected shape is extruded by the obstacles height along the y-axis.
Obstacles can be included in the navigation mesh baking process when NavigationObstacle3D.AffectNavigationMesh 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, e.g. inside "solid" geometry or on top of it. If NavigationObstacle3D.CarveNavigationMesh is enabled the baked shape will not be affected by offsets of the navigation mesh baking, e.g. the agent radius.
With NavigationObstacle3D.AvoidanceEnabled 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.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors1
NavigationObstacle3DConstructor
public NavigationObstacle3D();Properties9
AffectNavigationMeshProperty
public bool AffectNavigationMesh { get; set; }If enabled and parsed in a navigation mesh baking process the obstacle will discard source geometry inside its NavigationObstacle3D.Vertices and NavigationObstacle3D.Height defined shape.
AvoidanceEnabledProperty
public bool AvoidanceEnabled { get; set; }If true the obstacle affects avoidance using agents.
AvoidanceLayersProperty
public uint AvoidanceLayers { get; set; }A bitfield determining the avoidance layers for this obstacle. Agents with a matching bit on the their avoidance mask will avoid this obstacle.
CarveNavigationMeshProperty
public bool CarveNavigationMesh { get; set; }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 NavigationObstacle3D.AffectNavigationMesh to be enabled.
HeightProperty
public float Height { get; set; }Sets the obstacle height used in 2D avoidance. 2D avoidance using agents ignore obstacles that are below or above them.
RadiusProperty
public float Radius { get; set; }Sets the avoidance radius for the obstacle.
Use3DAvoidanceProperty
public bool Use3DAvoidance { get; set; }If true the obstacle affects 3D avoidance using agents with obstacle NavigationObstacle3D.Radius.
If false the obstacle affects 2D avoidance using agents with both obstacle NavigationObstacle3D.Vertices as well as obstacle NavigationObstacle3D.Radius.
VelocityProperty
public Vector3 Velocity { get; set; }The wanted velocity for the obstacle, used by other agents to better predict the obstacle if it is moved with a velocity regularly (every frame), instead of warped to a new position.
Note: This property only affects avoidance for the obstacle's NavigationObstacle3D.Radius. Does nothing for the obstacle's static vertices.
VerticesProperty
public Vector3[] Vertices { get; set; }The outline vertices of the obstacle. If the vertices are winded in clockwise order, agents will be pushed in by the obstacle, otherwise they will be pushed out. Outlines cannot be crossed or overlap. If the obstacle is warped to a new position, agents cannot predict this movement and may get trapped inside the obstacle.
Methods24
GetAffectNavigationMeshbool
public bool GetAffectNavigationMesh();boolGetAvoidanceEnabledbool
public bool GetAvoidanceEnabled();boolGetAvoidanceLayerValuebool
public bool GetAvoidanceLayerValue(int layerNumber);Returns whether or not the specified layer of the NavigationObstacle3D.AvoidanceLayers bitmask is enabled, given a layer_number between 1 and 32.
| Name | Type | Default |
|---|---|---|
layerNumber | int | — |
boolGetAvoidanceLayersuint
public uint GetAvoidanceLayers();uintGetCarveNavigationMeshbool
public bool GetCarveNavigationMesh();boolGetHeightfloat
public float GetHeight();floatGetNavigationMapRid
public Rid GetNavigationMap();Returns the Rid of the navigation map for this NavigationObstacle node. This function returns always the map set on the NavigationObstacle node and not the map of the abstract obstacle on the NavigationServer. If the obstacle map is changed directly with the NavigationServer API the NavigationObstacle node will not be aware of the map change. Use NavigationObstacle3D.SetNavigationMap to change the navigation map for the NavigationObstacle and also update the obstacle on the NavigationServer.
RidGetRadiusfloat
public float GetRadius();floatGetRidRid
public Rid GetRid();Returns the Rid of this obstacle on the NavigationServer3D.
RidGetUse3DAvoidancebool
public bool GetUse3DAvoidance();boolGetVelocityVector3
public Vector3 GetVelocity();Vector3GetVerticesVector3[]
public Vector3[] GetVertices();Vector3[]SetAffectNavigationMeshvoid
public void SetAffectNavigationMesh(bool enabled);| Name | Type | Default |
|---|---|---|
enabled | bool | — |
SetAvoidanceEnabledvoid
public void SetAvoidanceEnabled(bool enabled);| Name | Type | Default |
|---|---|---|
enabled | bool | — |
SetAvoidanceLayerValuevoid
public void SetAvoidanceLayerValue(int layerNumber, bool value);Based on value, enables or disables the specified layer in the NavigationObstacle3D.AvoidanceLayers bitmask, given a layer_number between 1 and 32.
| Name | Type | Default |
|---|---|---|
layerNumber | int | — |
value | bool | — |
SetAvoidanceLayersvoid
public void SetAvoidanceLayers(uint layers);| Name | Type | Default |
|---|---|---|
layers | uint | — |
SetCarveNavigationMeshvoid
public void SetCarveNavigationMesh(bool enabled);| Name | Type | Default |
|---|---|---|
enabled | bool | — |
SetHeightvoid
public void SetHeight(float height);| Name | Type | Default |
|---|---|---|
height | float | — |
SetNavigationMapvoid
public void SetNavigationMap(Rid navigationMap);Sets the Rid of the navigation map this NavigationObstacle node should use and also updates the obstacle on the NavigationServer.
| Name | Type | Default |
|---|---|---|
navigationMap | Rid | — |
SetRadiusvoid
public void SetRadius(float radius);| Name | Type | Default |
|---|---|---|
radius | float | — |
SetUse3DAvoidancevoid
public void SetUse3DAvoidance(bool enabled);| Name | Type | Default |
|---|---|---|
enabled | bool | — |
SetVelocityvoid
public void SetVelocity(Vector3 velocity);| Name | Type | Default |
|---|---|---|
velocity | Vector3 | — |
SetVertices2 overloads
public void SetVertices(Vector3[] vertices);| Name | Type | Default |
|---|---|---|
vertices | Vector3[] | — |
public void SetVertices(ReadOnlySpan<Vector3> vertices);| Name | Type | Default |
|---|---|---|
vertices | ReadOnlySpan<Vector3> | — |