This page has been translated automatically.
视频教程
界面
要领
高级
实用建议
UnigineEditor
界面概述
资产工作流程
设置和首选项
项目开发
调整节点参数
Setting Up Materials
Setting Up Properties
照明
Landscape Tool
Sandworm
使用编辑器工具执行特定任务
Extending Editor Functionality
嵌入式节点类型
Nodes
Objects
Effects
Decals
光源
Geodetics
World Objects
Sound Objects
Players
编程
基本原理
搭建开发环境
Usage Examples
UnigineScript
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine Tools
GUI
双精度坐标
应用程序接口
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
创建内容
Content Optimization
Materials
Art Samples
Tutorials
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

障碍物

An obstacle is an invisible object which is placed inside a navigation area and is bypassed during pathfinding.障碍物是放置在导航区域内的不可见对象,在寻路过程中会被绕过。

注意
If you change obstacle transformation, route will be automatically recalculated in order to avoid the obstacle.如果更改障碍物变换,则会自动重新计算路线,以避开障碍物。

The obstacles can be added to the scene:可以将障碍物添加到场景中:

  • As a single node to indicate an area or a node that should be avoided during pathfinding. However, if you change transformation of the node, the obstacle transformation won't change.作为单个节点来指示在寻路过程中应避免的区域或节点。但是,如果更改节点的变换,则障碍物变换不会改变。
  • As a child node of a node that should be bypassed. In this case, transformation of the obstacle will change together with the node transformation and a route will always be calculated correctly.作为应绕过的节点的子节点。在这种情况下,障碍物的变换将与节点变换一起更改,并且始终会正确计算路线。

There are 3 types of the obstacles:障碍分为3种类型:

You should choose the most appropriate type depending on the form of the node that should be bypassed during pathfinding.您应根据在寻路过程中应绕过的节点的形式选择最合适的类型。

Usage Example使用范例#

Supposing, you need to add a node that changes its transformation each frame and should be bypassed during pathfinding. In this case, you should do the following:假设您需要添加一个节点,该节点会在每帧中更改其变换,并且在寻路过程中应绕过该节点。在这种情况下,您应该执行以下操作:

  1. Place the required node inside the navigation area within which routes will be calculated.将所需的节点放置在将要计算路线的导航区域内。

    A cuboid-shaped ObjectMeshDynamic node placed inside the Navigation Sector放置在Navigation Sector内的长方体形状的ObjectMeshDynamic节点
  2. Add the obstacle of the required type to the scene and combine its position with the node's position.将所需类型的障碍物添加到场景中,并将其位置与节点的位置结合起来。
  3. Set the required size for the obstacle.设置障碍物所需的大小。

    The obstacle box and the node.障碍箱和节点。
  4. In the World Hierarchy window, drag the obstacle node to make it a child of the required node.World Hierarchy窗口中,将障碍物节点拖动到做个孩子所需节点的数量。

    注意
    This will enable to simultaneously change transformation of the node and the obstacle. You can also perform it via code.这将使得能够同时改变节点和障碍物的变换。您也可以执行通过代码
  5. Now you can create a route from the script. The route will be automatically recalculated when the node transformation changes.现在你可以创建一条路线从脚本。节点转换更改时,将自动重新计算路线。

In the result, the route will be calculated as follows (the route is highlighted with white):结果,将按以下方式计算路线(路线以白色突出显示):

The route that bypasses the node marked as the obstacle box绕过标记为障碍箱的节点的路线

See Also也可以看看#

最新更新: 2021-04-29
Build: ()