GFHomingProjectileMotion¶
API Reference / Combat / 类索引
- 路径:
addons/gf/extensions/combat/projectiles/gf_homing_projectile_motion.gd - 模块:
Combat - 继承:
GFProjectileMotion - API:
public - 类别:资源定义 (
resource_definition) - 首次版本:
3.17.0
2D/3D 通用追踪发射体移动策略。 目标可通过 launch() 上下文中的 target、target_position、target_position_2d 或 target_position_3d 传入,也可以用 target_path 从发射体节点相对查找。
成员概览¶
| 类型 | 名称 | 签名 |
|---|---|---|
| 属性 | speed |
var speed: float = 0.0 |
| 属性 | target_path |
var target_path: NodePath = NodePath("") |
| 属性 | target_context_key |
var target_context_key: StringName = &"target" |
| 属性 | target_position_context_key |
var target_position_context_key: StringName = &"target_position" |
| 属性 | arrival_distance |
var arrival_distance: float = 0.0 |
| 属性 | track_target |
var track_target: bool = true |
| 属性 | stop_when_reached |
var stop_when_reached: bool = true |
| 方法 | _setup |
func _setup(projectile: Node, projectile_context: Dictionary = {}) -> void: |
| 方法 | _step |
func _step(projectile: Node, delta: float, projectile_context: Dictionary = {}) -> void: |
属性¶
speed¶
- API:
public
每秒移动距离。
target_path¶
- API:
public
可选目标节点路径。为空时只读取 projectile_context。
target_context_key¶
- API:
public
从 projectile_context 读取目标对象或位置的键。
target_position_context_key¶
- API:
public
从 projectile_context 读取通用目标位置的键。
arrival_distance¶
- API:
public
到目标的距离小于等于该值时视为到达。小于 0 表示不标记到达。
track_target¶
- API:
public
是否每帧重新朝向当前目标。关闭后只在首次解析目标时锁定方向。
stop_when_reached¶
- API:
public
到达目标范围时是否停止并夹住位移,避免越过目标。
方法¶
_setup¶
- API:
protected
缓存初始追踪方向。
参数:
| 名称 | 说明 |
|---|---|
projectile |
发射体节点。 |
projectile_context |
本次发射上下文字典。 |
结构:
projectile_context: Dictionary,本次发射上下文;可包含 target、target_position、target_position_2d 或 target_position_3d。
_step¶
- API:
protected
推进追踪移动。
参数:
| 名称 | 说明 |
|---|---|
projectile |
发射体节点。 |
delta |
物理帧间隔。 |
projectile_context |
本次发射上下文字典。 |
结构:
projectile_context: Dictionary,本次发射上下文;会写入目标距离、速度和到达状态。