feat(game): 补齐角色预制体的characterDataName字段并优化英雄归位逻辑

- 为第一章和第二章共12个角色预制体补全characterDataName字段,
  包括人类士兵、弓箭手、法师、盾卫、精锐士兵、弓箭猎人、
  狼人、石巨人、蓝色怪物等角色

- 新增useAnchorLeash字段控制英雄锚点牵绳行为,避免英雄
  追击敌人时被推到地图边界外

- 修复UnitBase中stoppingDistance导致的导航问题,英雄归位
  现在采用正常行走而非瞬移方式

- 修正
This commit is contained in:
huadexuan committed 2026-10-05 14:21:46 +08:00
1 parent 7d9d0f52d1
commit 6089308f66
12 files changed
+16 -11

No files matched your search

+1 -1
View File
@@ -399,7 +399,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: da330bbd52e2a424dbe6231c018a3c60, type: 3}
m_Name:
m_EditorClassIdentifier:
characterDataName:
characterDataName: "\u4EBA\u7C7B\u58EB\u5175Data"
level: 1
speed: 5
detectionRange: 15
@@ -452,6 +452,7 @@ MonoBehaviour:
summonerMode: 0
returnToAnchorWhenIdle: 0
anchorArrivalDistance: 0.35
useAnchorLeash: 0
target: {fileID: 0}
--- !u!4 &6905509304330285822 stripped
Transform:
+1 -1
View File
@@ -360,7 +360,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: da330bbd52e2a424dbe6231c018a3c60, type: 3}
m_Name:
m_EditorClassIdentifier:
characterDataName:
characterDataName: "\u5F13\u7BAD\u624BData"
level: 1
speed: 5
detectionRange: 20
+1 -1
View File
@@ -415,7 +415,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: da330bbd52e2a424dbe6231c018a3c60, type: 3}
m_Name:
m_EditorClassIdentifier:
characterDataName:
characterDataName: "\u6CD5\u5E08Data"
level: 1
speed: 5
detectionRange: 20
+3 -3
View File
@@ -357,12 +357,12 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: da330bbd52e2a424dbe6231c018a3c60, type: 3}
m_Name:
m_EditorClassIdentifier:
characterDataName:
characterDataName: "\u76FE\u536BData"
level: 1
speed: 5
detectionRange: 15
attackRange: 1.5
modelFacingOffset: 90
attackRange: 2
modelFacingOffset: 45
attackPower: 10
attackDuration: 0
attackType: 0
+1 -1
View File
@@ -343,7 +343,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: da330bbd52e2a424dbe6231c018a3c60, type: 3}
m_Name:
m_EditorClassIdentifier:
characterDataName:
characterDataName: "\u7CBE\u9510\u58EB\u5175Data"
level: 1
speed: 5
detectionRange: 15
+1 -1
View File
@@ -445,7 +445,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: da330bbd52e2a424dbe6231c018a3c60, type: 3}
m_Name:
m_EditorClassIdentifier:
characterDataName:
characterDataName: "\u5F13\u7BAD\u730E\u4EBAData"
level: 1
speed: 5
detectionRange: 20
+1 -1
View File
@@ -255,7 +255,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: da330bbd52e2a424dbe6231c018a3c60, type: 3}
m_Name:
m_EditorClassIdentifier:
characterDataName:
characterDataName: "\u72C2\u66B4\u72FC\u4EBAData"
level: 1
speed: 5
detectionRange: 15
+1 -1
View File
@@ -265,7 +265,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: da330bbd52e2a424dbe6231c018a3c60, type: 3}
m_Name:
m_EditorClassIdentifier:
characterDataName:
characterDataName: "\u77F3\u5DE8\u4EBAData"
level: 1
speed: 5
detectionRange: 15
+1 -1
View File
@@ -244,7 +244,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: da330bbd52e2a424dbe6231c018a3c60, type: 3}
m_Name:
m_EditorClassIdentifier:
characterDataName:
characterDataName: "\u84DD\u8272\u602A\u7269Data"
level: 1
speed: 5
detectionRange: 15
Binary file not shown.
+4
View File
@@ -131,6 +131,10 @@
- [2026-10-04 11:15:47] 2026-10-04 DefenseTest 布阵区域改为 4×4 并与用户新建的 Plane 完全重合。DeployGrid 常量:Cols=4、Rows=4、ColStep=2.875、RowStep=2.8、BackZ=-14.2、CellWidth=2.815、CellDepth=2.74、GridY=0.115、UnitY=0.10(对齐重烘后的 NavMesh)。Plane 原在 y=0.5 会挡住单位,已降到 y=0.09 并放入 Buildings 层(layer 8)排除烘焙;NavMeshSurface 体积改为 center=(0,1,12) size=(28,12,62) 重烘,NavMesh 高度由 0.16 变 0.095,DefenseWaveLevelController.spawnY 同步改为 0.1。开始游戏按钮改为顶部居中(anchor 上中、anchoredPosition y=-170、420×120)。注意:BattlePlatform 实际只覆盖 Z -22.8..17.2,所以 NavMesh 远端也就到 ~16.9,敌人 spawnZ=20 本身在地面之外(靠 NavMeshAgent 自动吸附),这是既有行为。
- [2026-10-04 13:12:11] 2026-10-04 英雄打完归位改为"走回去"(正常速度),去掉瞬移。关键坑:UnitBase.Start 里 `navAgent.stoppingDistance = attackRange*0.95` 会让 agent 在到达锚点前就认为"已到达"而停住(法师 5.7 米、盾卫 0.95 米都远大于 anchorArrivalDistance 0.35),所以"走回锚点"以前根本走不到——这正是当初只能瞬移的原因。修法:ReturnToAnchor 里把 stoppingDistance 设 0,RestoreIdleSpeed/move() 里恢复 NormalStoppingDistance。另新增 useAnchorLeash/anchorLeashDistance(英雄设为 10 米,DefenseGameFlowController.heroLeashDistance 控制),目标距锚点超过上限就不追,避免一路推到 Z≈16。DefenseGameFlowController.ResetHeroPositions 现在只清 target 让 UnitBase 自己走回,仅当 NavMesh.SamplePosition 找不到落脚点(真卡住)才瞬移兜底。
- [2026-10-04 14:12:16] 2026-10-04 DefenseTest 两处修正:1) 阵位守护距离不再单开字段,直接用 UnitBase.detectionRange(已删除 anchorLeashDistance / heroLeashDistance;DefenseGameFlowController 只留开关 heroGuardPost=true,新 bool 字段在旧场景里会反序列化成 false,必须显式写进场景)。出战 5 个英雄 Prefab 的 detectionRange 已从 30/50 调到 10(弓箭手 12)。2) 底部英雄卡的角色改回从 PlayerData.json 的 currentDeck 读(站位不再读),卡面(头像/名字/稀有度)用同一份 CharacterData 刷新(新增 HeroCardUI.SetCharacterInfo,区别于绑定单位的 SetHero),否则会出现「卡面显示人类士兵、拖出来却是法师」的不一致;PlayerData 读不到时兜底用 HeroRoster。注意 CharacterData 里有些角色(荒野之王/荒野流寇等)unitPrefab 为空,不能出战,取阵容时要跳过。
- [2026-10-04 23:19:03] - [2026-10-04 22:20:00] CharacterData 真实字段名(猜错会导致 exec_editor_script 编译失败):baseMaxHealth / baseAttackPower / baseMoveSpeed / healthPerLevel / attackPerLevel / moveSpeedPerLevel / characterId / characterName / cardIcon / rarity / unitPrefab / description。**不存在** baseHealth / baseAttack。UnitBase 的“角色数据”字段是字符串 characterDataName,运行时 Resources.Load<CharacterData>($"Data/{name}"),资产放在 Assets/Resources/Data。
- [2026-10-04 23:19:03] - [2026-10-04 22:20:00] 批量改 prefab 上 UnitBase.characterDataName 的坑:AssetDatabase.FindAssets("名称 t:Prefab") 是模糊匹配(搜“盾卫”会命中“城堡金盾卫”),曾把城堡金盾卫误填成 盾卫Data(HP 700 顶替了 300)。**How to apply:** 批量改 prefab 字段必须用精确路径 AssetDatabase.LoadAssetAtPath<GameObject>(完整路径) 逐个处理,改完立刻回读全量校验,不能只看“Updated N”日志。
- [2026-10-04 23:19:03] - [2026-10-04 22:20:00] 第一章/第二章 共 12 个角色 prefab 的 characterDataName 已补齐并验证可加载(数值取自 Resources/Data)。映射留意:狼人.prefab 对应的是 狂暴狼人Data(资产名与文件不一致)。**未完成项:** 蓝角蛮卒.prefab 填的 蓝角蛮卒Data 在 Resources/Data 下不存在,运行时会打黄色警告并回退 Inspector 默认值 —— 待用户提供 HP/ATK/SPD 等数值或指定复用来源后再新建该资产。
- [2026-10-04 23:19:03] - [2026-10-04 22:20:00] exec_editor_script 参数规则(当前 Codely bridge 版本):enable_repl=false 时**不能**传 script_session_id,否则报 “was provided but enable_repl is false” 校验失败且脚本完全不执行;空字符串也报错。需要多轮排查就用 enable_repl=true 并复用返回的 session_id。违反会连续重复同一失败调用进而触发 tool loop 检测。
### Reference
- [2026-09-09 12:23:17] 飞行物脚本 Projectile.cs 负责锁敌追踪、碰撞检测和伤害结算。箭矢预制体 ArrowProjectile_White.prefab 已配置 Projectile 组件和 CapsuleCollider(Is Trigger)。远程单位需在攻击动画松弦帧添加 OnAttackEffect Event,并在 UnitBase 中设置 attackType=RangedProjectile、projectilePrefab、projectileSpawnPoint。