- 好友
- 6
- 在线时间
- 0 小时
- 最后登录
- 2026-10-23
见习骑士

- UID
- 3304622
- 第纳尔
- 685
- 精华
- 0
- 互助
- 26
- 荣誉
- 3
- 贡献
- 0
- 魅力
- 175
- 注册时间
- 2021-12-28
 鲜花( 32)  鸡蛋( 0)
|
本帖最后由 杰喵喵 于 2026-10-13 11:39 编辑
关于agent做动作时候,因视角盯着敌人出现旋转问题。再做马撞击,使用动作强制覆盖做撞击飞的敌人功能的时候发现一个很抽象的问题,因为马匹速度很快,被撞击的敌人做动作的时候依然会一致盯着骑手,这样就会出现马撞击冲过agent以后,agent一边做击飞动作一边旋转“看着”骑手。刚开始尝试使用agent_set_is_alarmed、agent_clear_relations_with_agents、什么清理agent关系,设定非警戒状态,都是浮云没有啥用,最后直接look自己一直的位置,解决。
代码如下:
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,
- [4, "ani_fall_flyback3_med_rise",0,64, arf_blend_in_2,0, (0, -3, 0), 0.0],
- ],
-
- ["ani_fall_fly_back_end", 0, amf_play,
- [1, "anim_human", 50, 52, arf_blend_in_16],
- ],
- ["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,
- [4, "ani_fall_flyfront_rise",0,85,arf_blend_in_2,0, (0, 2, 0), 0.0],
- ],
-
- ["ani_fall_fly_forward_end", 0, amf_play,
- [1, "anim_human", 50, 52, arf_blend_in_16],
- ],
复制代码
2.ti_on_agent_hit + 0.1秒定时器业务功能代码:
- (ti_on_agent_hit, 0, 0, [],
- [
- (set_fixed_point_multiplier, 100),
- (store_trigger_param, ":victim", 1), # 被击中者
- (store_trigger_param, ":dealer", 2), # 攻击者
- # ---------- dealer 不是 human → 就是马 agent ----------
- (neg|agent_is_human, ":dealer"),
- (agent_get_rider, ":rider_agent_no",":dealer"),
- (gt,":rider_agent_no",0),
- # ---------- victim 是步兵 (没上马的 human) ----------
- (agent_is_alive, ":victim"),
- (agent_is_human, ":victim"),
- (agent_get_horse, ":dummy", ":victim"),
- (lt, ":dummy", 0),
- # ---------- 方向判定 + 播击飞动作 ----------
- # 局部坐标: pos70 = victim 的坐标系, pos71 = dealer(马) 在其中
- (agent_get_position, pos70, ":victim"),
- (agent_get_position, pos71, ":dealer"),
- (position_transform_position_to_local, pos72, pos70, pos71),
- (position_get_y, ":local_y", pos72),
- (try_begin),
- (gt, ":local_y", 0),
- (agent_set_animation, ":victim", "anim_ani_fall_fly_back"), # 迎面撞 → 向后飞
- (else_try),
- (agent_set_animation, ":victim", "anim_ani_fall_fly_forward"), # 侧 / 后 → 向前扑
- (try_end),
- ]),
-
- # ================================================================
- # 击飞状态机 —— 每 0.1 秒扫一次, 只处理 AI 士兵
- # ================================================================
- (0.1, 0, 0, [],
- [
- (get_player_agent_no, ":player_agent"),
- (try_for_agents, ":agent"),
- # ---- 只针对 AI 士兵 ----
- (agent_is_active, ":agent"),
- (agent_is_alive, ":agent"),
- (agent_is_human, ":agent"),
- (neg|eq, ":agent", ":player_agent"),
- (agent_get_horse, ":horse", ":agent"),
- (lt, ":horse", 0),
- (agent_get_animation, ":cur_anim", ":agent"),
- (try_begin),
- # ---- ① 正处于击飞动作 ----
- (eq|this_or_next, ":cur_anim", "anim_ani_fall_fly_back"),
- (eq, ":cur_anim", "anim_ani_fall_fly_forward"),
- (agent_get_position, pos70, ":agent"),
- (agent_set_look_target_position, ":agent", pos70),
- (try_end),
- (try_end),
- ]),
复制代码
|
鲜花鸡蛋ease 在2026-10-13 18:16 送朵鲜花 并说:我非常同意你的观点,送朵鲜花鼓励一下
|