GFSteeringBehaviorResource¶
API Reference / Standard / 类索引
- 路径:
addons/gf/standard/foundation/math/gf_steering_behavior_resource.gd - 模块:
Standard - 继承:
Resource - API:
public - 类别:资源定义 (
resource_definition) - 首次版本:
3.17.0
可资源化配置的 steering 行为。 包装 GFSteeringMath 的纯算法,允许项目用 Resource 组合 seek、arrive、avoid 等 通用行为。动态目标、邻居和路径通过 context 传入,避免把业务对象写死进资源。
成员概览¶
| 类型 | 名称 | 签名 |
|---|---|---|
| 枚举 | BehaviorType |
enum BehaviorType |
| 属性 | behavior_type |
var behavior_type: BehaviorType = BehaviorType.SEEK |
| 属性 | enabled |
var enabled: bool = true |
| 属性 | weight |
var weight: float = 1.0 |
| 属性 | target_position |
var target_position: Vector3 = Vector3.ZERO |
| 属性 | target_orientation |
var target_orientation: float = 0.0 |
| 属性 | arrival_radius |
var arrival_radius: float = 4.0 |
| 属性 | slow_radius |
var slow_radius: float = 64.0 |
| 属性 | time_to_target |
var time_to_target: float = 0.1 |
| 属性 | align_tolerance |
var align_tolerance: float = 0.001 |
| 属性 | slow_angle |
var slow_angle: float = 0.5 |
| 属性 | use_z_axis |
var use_z_axis: bool = false |
| 属性 | max_prediction_seconds |
var max_prediction_seconds: float = 1.0 |
| 属性 | decay_coefficient |
var decay_coefficient: float = 1.0 |
| 属性 | max_distance |
var max_distance: float = -1.0 |
| 属性 | collision_radius |
var collision_radius: float = -1.0 |
| 属性 | minimum_separation |
var minimum_separation: float = -1.0 |
| 属性 | path_offset |
var path_offset: float = 0.0 |
| 方法 | calculate |
func calculate(agent: GFSteeringAgent, context: Dictionary = {}) -> GFSteeringAcceleration: |
| 方法 | duplicate_behavior |
func duplicate_behavior() -> Resource: |
枚举¶
BehaviorType¶
- API:
public
enum BehaviorType { ## 朝目标位置加速。 SEEK, ## 远离目标位置。 FLEE, ## 抵达目标位置并减速。 ARRIVE, ## 追逐目标代理。 PURSUE, ## 躲避目标代理。 EVADE, ## 面向目标位置。 FACE, ## 朝当前速度方向转向。 LOOK_WHERE_YOU_GO, ## 对齐指定朝向。 ALIGN, ## 与邻居保持距离。 SEPARATION, ## 朝邻居中心靠拢。 COHESION, ## 基于预测最近距离避让碰撞。 AVOID_COLLISIONS, ## 沿路径计算目标点并 seek。 PATH_FOLLOW_SEEK, }
Steering 行为类型。
属性¶
behavior_type¶
- API:
public
行为类型。
enabled¶
- API:
public
是否启用该行为。
weight¶
- API:
public
组合时使用的权重。
target_position¶
- API:
public
静态目标位置;context 中的 target_position 会覆盖该值。
target_orientation¶
- API:
public
静态目标朝向;context 中的 target_orientation 会覆盖该值。
arrival_radius¶
- API:
public
抵达半径。
slow_radius¶
- API:
public
减速半径。
time_to_target¶
- API:
public
逼近期望时间。
align_tolerance¶
- API:
public
角度对齐容差。
slow_angle¶
- API:
public
开始角速度减速的角度。
use_z_axis¶
- API:
public
3D 转向是否使用 x/z 平面。
max_prediction_seconds¶
- API:
public
目标预测最大秒数。
decay_coefficient¶
- API:
public
分离行为距离衰减系数。
max_distance¶
- API:
public
最大影响距离;小于 0 时由算法使用代理半径。
collision_radius¶
- API:
public
避让碰撞半径;小于 0 时由算法使用双方半径。
minimum_separation¶
- API:
public
避让最小分离距离;小于 0 时由算法使用碰撞半径。
path_offset¶
- API:
public
路径跟随前进偏移。
方法¶
calculate¶
- API:
public
计算 steering 加速度。
参数:
| 名称 | 说明 |
|---|---|
agent |
代理状态。 |
context |
动态上下文,支持 target_position、target_orientation、target_agent、neighbors、targets、path。 |
返回:steering 加速度。
结构:
context: Dictionary steering behavior context with optional target_position, target_orientation, target_agent, neighbors, targets, and path.
duplicate_behavior¶
- API:
public
创建配置副本。
返回:新行为资源。