骑马与砍杀中文站论坛

 找回密码
 注册(Register!)

QQ登录

只需一步,快速开始

搜索
购买霸主CDKEY 购买战帆CDKEY
查看: 114|回复: 0

[功能与代码] 关于agent做动作时候,因视角盯着敌人出现旋转问题

[复制链接]

17

主题

141

回帖

207

积分

见习骑士

Rank: 3

UID
3304622
第纳尔
685
精华
0
互助
26
荣誉
3
贡献
0
魅力
175
注册时间
2021-12-28
鲜花(32) 鸡蛋(0)
发表于 2026-10-13 11:35:31 | 显示全部楼层 |阅读模式
本帖最后由 杰喵喵 于 2026-10-13 11:39 编辑

关于agent做动作时候,因视角盯着敌人出现旋转问题。再做马撞击,使用动作强制覆盖做撞击飞的敌人功能的时候发现一个很抽象的问题,因为马匹速度很快,被撞击的敌人做动作的时候依然会一致盯着骑手,这样就会出现马撞击冲过agent以后,agent一边做击飞动作一边旋转“看着”骑手。刚开始尝试使用agent_set_is_alarmed、agent_clear_relations_with_agents、什么清理agent关系,设定非警戒状态,都是浮云没有啥用,最后直接look自己一直的位置,解决。

代码如下:
1.动作设定与标志位参数
  1. ["ani_fall_fly_back", acf_enforce_all|acf_align_with_ground|acf_displace_position|acf_lock_camera, amf_play|amf_priority_die|amf_accurate_body|amf_client_prediction|amf_continue_to_next,
  2. [4, "ani_fall_flyback3_med_rise",0,64, arf_blend_in_2,0, (0, -3, 0), 0.0],
  3. ],



  4. ["ani_fall_fly_back_end", 0, amf_play,
  5.   [1, "anim_human", 50, 52, arf_blend_in_16],
  6. ],


  7. ["ani_fall_fly_forward", acf_enforce_all|acf_align_with_ground|acf_displace_position|acf_lock_camera, amf_play|amf_priority_die|amf_accurate_body|amf_client_prediction|amf_continue_to_next,
  8. [4, "ani_fall_flyfront_rise",0,85,arf_blend_in_2,0, (0, 2, 0), 0.0],
  9. ],



  10. ["ani_fall_fly_forward_end", 0, amf_play,
  11.   [1, "anim_human", 50, 52, arf_blend_in_16],
  12. ],
复制代码

2.ti_on_agent_hit + 0.1秒定时器业务功能代码:
  1. (ti_on_agent_hit, 0, 0, [],
  2.   [
  3.     (set_fixed_point_multiplier, 100),

  4.     (store_trigger_param, ":victim", 1),       # 被击中者
  5.     (store_trigger_param, ":dealer", 2),       # 攻击者

  6.     # ---------- dealer 不是 human → 就是马 agent ----------
  7.     (neg|agent_is_human, ":dealer"),
  8.     (agent_get_rider, ":rider_agent_no",":dealer"),
  9.     (gt,":rider_agent_no",0),

  10.     # ---------- victim 是步兵 (没上马的 human) ----------
  11.     (agent_is_alive, ":victim"),
  12.     (agent_is_human, ":victim"),
  13.     (agent_get_horse, ":dummy", ":victim"),
  14.     (lt, ":dummy", 0),

  15.     # ---------- 方向判定 + 播击飞动作 ----------
  16.     # 局部坐标: pos70 = victim 的坐标系, pos71 = dealer(马) 在其中
  17.     (agent_get_position, pos70, ":victim"),
  18.     (agent_get_position, pos71, ":dealer"),
  19.     (position_transform_position_to_local, pos72, pos70, pos71),
  20.     (position_get_y, ":local_y", pos72),
  21.     (try_begin),
  22.       (gt, ":local_y", 0),
  23.       (agent_set_animation, ":victim", "anim_ani_fall_fly_back"),      # 迎面撞 → 向后飞
  24.     (else_try),
  25.       (agent_set_animation, ":victim", "anim_ani_fall_fly_forward"),   # 侧 / 后 → 向前扑
  26.     (try_end),

  27.   ]),


  28.   
  29.   # ================================================================
  30.   # 击飞状态机 —— 每 0.1 秒扫一次, 只处理 AI 士兵
  31.   # ================================================================
  32.   (0.1, 0, 0, [],
  33.   [
  34.     (get_player_agent_no, ":player_agent"),
  35.     (try_for_agents, ":agent"),
  36.       # ---- 只针对 AI 士兵 ----
  37.       (agent_is_active, ":agent"),
  38.       (agent_is_alive, ":agent"),
  39.       (agent_is_human, ":agent"),
  40.       (neg|eq, ":agent", ":player_agent"),
  41.       (agent_get_horse, ":horse", ":agent"),
  42.       (lt, ":horse", 0),
  43.       (agent_get_animation, ":cur_anim", ":agent"),
  44.       (try_begin),
  45.         # ---- ① 正处于击飞动作 ----
  46.         (eq|this_or_next, ":cur_anim", "anim_ani_fall_fly_back"),
  47.         (eq, ":cur_anim", "anim_ani_fall_fly_forward"),
  48.         (agent_get_position, pos70, ":agent"),
  49.         (agent_set_look_target_position, ":agent", pos70),
  50.       (try_end),
  51.     (try_end),
  52.   ]),
复制代码




鲜花鸡蛋

ease  在2026-10-13 18:16  送朵鲜花  并说:我非常同意你的观点,送朵鲜花鼓励一下
您需要登录后才可以回帖 登录 | 注册(Register!)

本版积分规则

Archiver|手机版|小黑屋|骑马与砍杀中文站

GMT+8, 2026-10-23 21:19 , Processed in 0.072211 second(s), 19 queries , Gzip On, MemCached On.

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表