跳转至

GFSteeringBehaviorStack

API Reference / Standard / 类索引

  • 路径:addons/gf/standard/foundation/math/gf_steering_behavior_stack.gd
  • 模块:Standard
  • 继承:Resource
  • API:public
  • 类别:资源定义 (resource_definition)
  • 首次版本:3.17.0

资源化 steering 行为组合。 以 blend 或 priority 模式组合 GFSteeringBehaviorResource。它只返回加速度结果, 不负责移动节点、应用物理或解释项目 AI 状态。

成员概览

类型 名称 签名
枚举 CompositionMode enum CompositionMode
属性 mode var mode: CompositionMode = CompositionMode.BLEND
属性 behaviors var behaviors: Array[GFSteeringBehaviorResource] = []
属性 max_linear var max_linear: float = -1.0
属性 max_angular var max_angular: float = -1.0
属性 priority_threshold var priority_threshold: float = 0.001
方法 add_behavior func add_behavior(behavior: GFSteeringBehaviorResource) -> bool:
方法 is_empty func is_empty() -> bool:
方法 calculate func calculate(agent: GFSteeringAgent, context: Dictionary = {}) -> GFSteeringAcceleration:
方法 duplicate_stack func duplicate_stack() -> Resource:

枚举

CompositionMode

  • API:public
enum CompositionMode { ## 按权重混合所有行为。 BLEND, ## 选择第一个超过阈值的行为。 PRIORITY, }

行为组合方式。

属性

mode

  • API:public
var mode: CompositionMode = CompositionMode.BLEND

组合方式。

behaviors

  • API:public
var behaviors: Array[GFSteeringBehaviorResource] = []

行为列表。

max_linear

  • API:public
var max_linear: float = -1.0

混合后最大线性加速度;小于 0 时使用 agent 上限。

max_angular

  • API:public
var max_angular: float = -1.0

混合后最大角加速度;小于 0 时使用 agent 上限。

priority_threshold

  • API:public
var priority_threshold: float = 0.001

Priority 模式下判断非零的阈值。

方法

add_behavior

  • API:public
func add_behavior(behavior: GFSteeringBehaviorResource) -> bool:

添加行为。

参数:

名称 说明
behavior 行为资源。

返回:添加成功返回 true。

is_empty

  • API:public
func is_empty() -> bool:

检查是否没有有效行为。

返回:没有有效行为时返回 true。

calculate

  • API:public
func calculate(agent: GFSteeringAgent, context: Dictionary = {}) -> GFSteeringAcceleration:

计算组合后的 steering 加速度。

参数:

名称 说明
agent 代理状态。
context 传给每个行为的动态上下文。

返回:steering 加速度。

结构:

  • context: Dictionary steering behavior context passed to each behavior.

duplicate_stack

  • API:public
func duplicate_stack() -> Resource:

创建配置副本。

返回:新行为组合。