跳到主要内容

find_straight_path

获取起始位置到目标位置的路径

声明

array find_straight_path(Vec3 spos, Vec3 epos, map opt_args = nil)

参数

参数名描述
spos
epos
opt_args- max_path_size: 最大路径长度(顶点数)
- walkable_bits: 被打上标记的地块默认不可通行。该字段用于在本次寻路中取消特定类型的通行限制(当前最多支持64位有效标记)

返回值

  • 寻路成功:[info, (partial) path]
  • 返回部分结果(路径前缀)
  • 终点不可达,寻路结果尽可能接近终点:info.partial_result = true
  • 路径缓冲区(max_path_size)太小:info.buffer_too_small = true
  • 查询对象限制(max_nodes参数太小):info.out_of_nodes = true
  • 返回全部结果
  • 寻路失败(起点或终点在可行走区域外):[nil, nil]

使用方式

返回文档