Files
agame/.workbuddy/memory/2026-09-21.md
T
2026-09-21 16:52:27 +08:00

44 lines
4.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 2026-09-21
## 接入 godot-ai MCP(已完成并验证)
- 把 Claude Desktop 的 `godot-ai` MCP 迁入 WorkBuddy 配置 `C:\Users\DHXY\.workbuddy\mcp.json`,与原有 `unityMCP` 并存。
- 启动方式:`uvx.exe` + `--isolated --no-config ... --from godot-ai==4.1.0 godot-ai attach --port 8001 --ws-port 8002`。
- 去掉了原配置中 `pythonw.exe` 包一层隐藏控制台的写法,直接走 uvx stdio。
- 环境核实:`uvx.exe` 存在;Godot v4.7.2 mono 运行中,8001/8002 均 LISTEN;`addons/godot_ai/plugin.cfg` 版本 4.1.0 与服务端 pin 版本一致。
- **已信任并实测通过**:`project_manage(op="settings_get", key="application/config/name")` → `agame`。
## 经验:MCP 信任入口位置
- 「自定义连接器 / 信任 MCP」不在侧边栏连接器列表里,而在 **「连接器」页顶栏 →「MCP 服务管理」弹窗 →「我的 MCP」列表**,每个服务右侧是启用开关(绿色圆点=已连接)。
- 相关 i18n key(从 app.asar 反查得到):`connectorPanel.customConnector`=自定义连接器、`unifiedMarket.customConnector`=自定义连接器(市场页顶部「+」下拉里)。
## 本机环境补充(重要)
- `.workbuddy/memory` 下的文件在本会话中被外部清理过一次,写入后需复核是否仍在。
- Bash 工具完全不可用(`mkdir`/`dirname` 都不存在),PowerShell 可用但需把输出写文件再 Read;Glob/Grep 对 `.workbuddy` 这类点目录不可靠,用 Read 直接读或 PowerShell 列目录。
- PowerShell 里 `Add-Type` 被安全策略拦截,无法用 .NET API 激活窗口。
## 新建:第三人称控制器(胶囊体占位)
- 文件:`res://player/player.gd`、`res://player/player.tscn`、`res://world/main.tscn`(测试场地,已设为 main scene)。
- 结构:Player(CharacterBody3D,不旋转) / Collision + Body(Node3D,视觉层朝移动方向转) / Mesh + CameraRig / SpringArm / Camera。
- **关键教训**:相机臂不要挂在会旋转的本体下,否则按方向键会产生「相机跟着转」的螺旋轨迹(实测偏航 90°、直行无横向位移)。
- 输入动作(已写入 project.godot):move_forward/back/left/right(WASD+方向键)、jump(Space)、sprint(Shift)。
- 参数:走 5.0 / 跑 8.5 m/s,加速度 45(地面)/12(空中),跳跃初速 5.0(实测最高点 1.318 m)。
## 本机/工程改造记录
- `autoload/steamworks.gd`:Steam 初始化失败时原来直接 `get_tree().quit()`,导致没开 Steam 客户端时游戏秒退;已加 `OS.has_feature("editor")` 豁免(编辑器内返回不退出,发布版行为不变)。
## godot-ai MCP 使用要点(踩坑记录)
1. **路径是相对「当前编辑场景根」**,且要带根节点名,如 `/Player/CameraRig/SpringArm`;`parent_path: ""` 表示当前场景根。切场景后所有路径的含义会变,写操作前先确认 `editor_state.current_scene`。
2. **`is_action_just_pressed()` 在 `_physics_process` 里对调试器注入的输入无效**(注入发生在渲染帧,物理帧号已 +1)。要么用 `_unhandled_input` 收事件 + 输入缓冲,要么只能读 `is_action_pressed()`。
3. `game_eval` 里 `var x := Engine.get_main_loop().current_scene` 会编译不过(类型推断),要 `var tree := Engine.get_main_loop() as SceneTree` 并且给节点变量显式类型。
4. `game_eval` 里的语法错误会把游戏卡进调试器断点(`game_status.status == "break"`),此后工具全部失效,必须 `project_manage(op="stop")` 后重启。
5. 布尔属性写入会报 `WRONG_TYPE: Cannot write String to a bool property`(`Camera3D.current` 试过),改用其他方式或接受默认行为(只有一台相机时 Godot 会自动启用)。
6. `SpringArm3D` 只在运行时摆放子节点;编辑器里预览要在场景里把相机 position.z 写成 spring_length 的值(已写入 player.tscn = 4.0)。
7. 验证玩法用 `game_manage(op="input_sequence")`;涉及 `just_pressed` 的场景改用 `game_eval` + `Input.parse_input_event` + `await tree.physics_frame` 循环采样。