This page has been translated automatically.
视频教程
界面
要领
高级
实用建议
基础
专业(SIM)
UnigineEditor
界面概述
资源工作流程
Version Control
设置和首选项
项目开发
调整节点参数
Setting Up Materials
设置属性
照明
Sandworm
使用编辑器工具执行特定任务
如何擴展編輯器功能
嵌入式节点类型
Nodes
Objects
Effects
Decals
光源
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
编程
基本原理
搭建开发环境
使用范例
C++
C#
UnigineScript
统一的Unigine着色器语言 UUSL (Unified UNIGINE Shader Language)
Plugins
File Formats
材质和着色器
Rebuilding the Engine Tools
GUI
双精度坐标
应用程序接口(API)参考
Animations-Related Classes
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes
VR-Related Classes
创建内容
内容优化
材质
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials

Navigation

Navigation Mesh 2D#

This sample demonstrates how to calculate and visualize 2D navigation paths using the Navigation Mesh object and PathRoute class via the C# API. It shows how to build a route between two points on a navigation mesh and renders the result for debugging or visualization purposes.

The main logic is implemented in the PathRoute2D component, which initializes a PathRoute class instance and uses PathRoute.Create2D() to compute the path from a start node to a finish node. If the route is successfully resolved, the path is drawn on screen using RenderVisualizer(). The radius parameter is set manually to ensure the generated path accounts for the navigation agent's size, avoiding collisions with nearby geometry.

The sample includes a second component, NavigationMeshVisualizer, that renders the Navigation Mesh during runtime to help visualize navigable areas.

This setup is useful for prototyping AI navigation, testing route validity, and analyzing the structure of navigable areas in 2D gameplay scenarios.


SDK Path: <SDK_INSTALLATION>data/csharp_component_samples/navigation/navigation_mesh_2d

Navigation Mesh Demo 2D#

This sample demonstrates how to implement dynamic 2D pathfinding using a Navigation Mesh object, with autonomous robots navigating toward randomly positioned targets. Each robot uses a PathRoute class instance to calculate a valid route within the navigation mesh and moves along it in real time.

The main logic is implemented in the PathRoute2DWithTarget component. On initialization, it creates a coin from a Node Reference and places it at a random valid location inside the Navigation Mesh. A PathRoute instance is initialized with a defined agent radius to ensure the generated path accounts for the agent's size, avoiding collisions with nearby geometry.

At runtime, the component continuously checks whether the robot is near its current target. If so, the target is moved to a new valid position, and a new path is generated using Create2D(). If the route is valid, the path is drawn on screen using RenderVisualizer() and the robot moves forward along it and smoothly adjusts its orientation using quaternion interpolation.

The sample includes a second component, NavigationMeshVisualizer, that renders the actual mesh structure during runtime to help visualize navigable areas.

This setup is useful for prototyping simple AI behavior such as patrolling or target chasing, where agents continuously search for and move toward dynamic goals.


SDK Path: <SDK_INSTALLATION>data/csharp_component_samples/navigation/navigation_mesh_demo_2d

Navigation Obstacles 2D#

This sample demonstrates how to use dynamic Obstacles in combination with a Navigation Mesh to influence 2D pathfinding in runtime. When an obstacle overlaps the navigation mesh, it temporarily modifies the traversable area, forcing the pathfinding algorithm to recalculate a valid route around it.

The main logic is implemented in the PathRoute2D component, which initializes a PathRoute class instance and uses PathRoute.Create2D() to compute the path from a start node to a finish node. If the route is successfully resolved, the path is drawn on screen using RenderVisualizer(). The radius parameter is set manually to ensure the generated path accounts for the navigation agent's size, avoiding collisions with nearby geometry.

To demonstrate dynamic behavior, several Obstacles are moved using the Rotator component, which continuously rotates them during runtime. This setup allows you to observe how the path is recalculated when obstacles shift position and alter the available navigation space.

This example is useful for prototyping interactive environments, where navigation must adapt to moving objects, barriers, or other gameplay elements affecting traversal.


SDK Path: <SDK_INSTALLATION>data/csharp_component_samples/navigation/navigation_obstacles_2d

Navigation Sectors 2D#

This sample demonstrates how to calculate and visualize 2D navigation paths using the Navigation Sector objects and PathRoute class. Unlike navigation meshes, sectors allow defining modular navigable areas that can be enabled, disabled, or moved dynamically at runtime.

The main logic is implemented in the PathRoute2D component, which creates a PathRoute class instance and uses Create2D() to compute a path through the active navigation sectors. If the route is successfully resolved, the path is drawn on screen using RenderVisualizer(). The radius parameter is set manually to ensure the generated path accounts for the agent's size, avoiding collisions with nearby geometry.

To help visualize active navigation areas, the NavigationSectorVisualizer component renders the geometry of all sectors during runtime.

Sectors are especially useful when navigation space needs to change at runtime - for example, if parts of the environment become inaccessible. Pathfinding requires sectors to be properly connected (their edges must overlap).

This 2D version is well-suited for top-down navigation, grid-based layouts, or layered 2D gameplay. For more complex 3D navigation scenarios, see the navigation_sectors_3d sample.


SDK Path: <SDK_INSTALLATION>data/csharp_component_samples/navigation/navigation_sectors_2d

Navigation Sectors 3D#

This sample demonstrates how to calculate and visualize 3D navigation paths using the Navigation Sector objects and PathRoute class via the C# API. Unlike navigation meshes, sectors allow defining modular navigable areas that can be enabled, disabled, or moved dynamically at runtime.

The main logic is implemented in the PathRoute3D component, which creates a PathRoute class instance and uses Create3D() to compute a path through the active navigation sectors. If the route is successfully resolved, the path is drawn on the screen using RenderVisualizer(). The radius parameter is set manually to ensure the generated path accounts for the agent's size, avoiding collisions with nearby geometry.

To help visualize active navigation areas, the NavigationSectorVisualizer component renders the geometry of all sectors during runtime.

Sectors are especially useful when navigation space needs to change at runtime - for example, if parts of the environment become inaccessible. Pathfinding requires sectors to be properly connected (their edges must overlap).

This setup is useful for multilevel structures or modular environments where the layout changes dynamically. For simpler 2D navigation scenarios, see the navigation_sectors_2d sample.


SDK Path: <SDK_INSTALLATION>data/csharp_component_samples/navigation/navigation_sectors_3d

Navigation Sectors Demo 3D#

This sample demonstrates how to implement 3D pathfinding logic using Navigation Sector and PathRoute class via the C# API. Robots autonomously fly and collect coins, which are dynamically placed at random locations within the navigation sector volume.

The main logic is implemented in the PathRoute3DWithTarget component. A PathRoute object is created to calculate a valid 3D path from the robot's current position to the target using PathRoute.Create3D(). Once a valid path is generated, the robot rotates toward the next point in the path and moves forward. If the path becomes invalid - for example, if the target ends up in an unreachable area, then the system selects a new target location and recalculates the route.

Target positions are chosen at random inside the volume of a Navigation Sector, using Inside3D() for validation. The route is automatically updated as the robot approaches the target. If the route is successfully resolved, the path is drawn on screen using RenderVisualizer().

To help visualize active navigation areas, the NavigationSectorVisualizer component renders the geometry of all sectors during runtime.

This setup is well-suited for implementing autonomous navigation in 3D volume, where both the moving objects and their targets can change position during runtime within a defined navigable area.


SDK Path: <SDK_INSTALLATION>data/csharp_component_samples/navigation/navigation_sectors_demo_3d

The information on this page is valid for UNIGINE 2.20 SDK.

Last update: 2025-06-30
Build: ()