SgObstacle
A placeable dynamic navigation obstacle for Tile cache nav meshes. On play the obstacle is registered with the linked SgNavMesh tile cache; in the editor a wireframe helper shows its shape (never during play).
Supported shapes: Box and Cylinder.
Inherits from
Setup
- Add an SgNavMesh with type Tile cache and bake it.
- Add an SgObstacle, assign the Nav mesh field, and choose Shape.
- Size the obstacle with half extents (box) or radius / height (cylinder).
- Optionally toggle Always show helper for the editor wireframe.
create
Create a new dynamic navmesh obstacle in the scenegraph.
Parameters
selfoptions(table): A table of options to fill the parametersparent(SceneObject): The parent scene object to add this to
Returns
Promise: promise which will resolve to the created object
Example
SgObstacle.create({
name = "DoorObstacle",
navMesh = navMeshNode,
shape = SgObstacle.Shape.Box,
halfExtents = Vector3.new(0.5, 1, 0.1),
alwaysShowHelper = true,
})
Properties
You can access these properties directly on the object (preferred), for example obj.active = true or local v = obj.active. The :get("propertyName") / :set("propertyName", value) methods also work, but prefer direct property access in examples and scripts.
| Property | Type | Default | Description |
|---|---|---|---|
| active | Boolean | true | A Boolean attribute indicating whether the 3D object is active or not. When set to true, the object is considered active in the scene. |
| static | Boolean | false | Marks the object as immovable during play. Static objects ignore transform changes at runtime and use a fixed physics collider with zero mass. |
| transform | Transform | Transform.new() | Specifies the transformation properties of the 3D object, including its position, rotation, and scale in the scene. |
| layers | Layers | [0] | Determines the layers the 3D object belongs to. Layers are used to organize objects in the scene for various purposes like rendering and interaction. |
| tags | Tags | [] | A list of tags associated with the 3D object. Tags are used for categorizing and identifying objects for scripting and scene management. |
| rendered | Boolean | true | When disabled, the object and its descendants are not drawn, but may still simulate physics or run scripts. |
| navMesh | Node | Target SgNavMesh (must use Tile cache mode) that receives this dynamic obstacle. | |
| shape | Enum | Box | Obstacle shape registered with the navmesh tile cache. | Options: Box, Cylinder |
| alwaysShowHelper | Boolean | true | Show a wireframe helper in the editor. Helpers are never shown during play. |
Enum: Shape
Enumeration of obstacle shapes.
| Field Name | Description |
|---|---|
| Box | string: Axis-aligned box obstacle (yaw from transform) |
| Cylinder | string: Vertical cylinder obstacle |