This commit is contained in:
2026-08-19 20:01:10 +08:00
parent dac32abdc4
commit 65682d5056
206 changed files with 1003 additions and 15612 deletions
@@ -467,6 +467,24 @@ public class MonsterContral : MonoBehaviour
// 路径结束后自动销毁
//StartCoroutine(yanchi(gameObject, time, isyuzhen));
// ⭐ 使用 OnEnable 缓存的 _cachedChild,避免每帧 transform.GetChild(0) 调用开销
// 兜底:缓存丢失时重新获取一次(理论上不会发生)
Transform child = _cachedChild;
if (child == null)
{
if (transform.childCount == 0) return;
child = transform.GetChild(0);
_cachedChild = child;
}
Vector3 localPos = child.localPosition;
// ⭐ x/y 归零摆正模型;z 深度只在显式配置 depthOffset(≠0)时才覆盖,
// 否则保留预制体上设置的 3D 深度(3D Boss 用,之前被强制归零导致深度无效)
localPos.x = 0f;
if (depthOffset != 0)
localPos.z = depthOffset;
child.localPosition = localPos;
}
public IEnumerator yanchi(GameObject obj, float time, bool isyuzhen)
{
@@ -609,7 +627,8 @@ public class MonsterContral : MonoBehaviour
{
Vector2 pos = _yzStartWorld + (Vector3)(_yzLineDir * transform.up * moveTime
* monsterData.moveLine.moveTime);
transform.position = pos;
// ⭐ 保留根节点当前 z(2D 小鱼 z 一直为 0,行为不变)
transform.position = new Vector3(pos.x, pos.y, transform.position.z);
return;
}
@@ -631,7 +650,8 @@ public class MonsterContral : MonoBehaviour
Vector2 pos = startWorld + (Vector3)(dir * transform.up * moveTime
* monsterData.moveLine.moveTime);
transform.position = pos;
// ⭐ 保留根节点当前 z(2D 小鱼 z 一直为 0,行为不变)
transform.position = new Vector3(pos.x, pos.y, transform.position.z);
break;
}
@@ -644,7 +664,8 @@ public class MonsterContral : MonoBehaviour
Vector2 next = monsterData.moveLine.GetBezierPointJob(moveTime);
if (fishenum != FishTypeEnum.Boss鱼)
ApplyFacingDirection(next);
transform.position = next;
// ⭐ 保留根节点当前 z(2D 小鱼 z 一直为 0,行为不变)
transform.position = new Vector3(next.x, next.y, transform.position.z);
break;
}
@@ -661,7 +682,9 @@ public class MonsterContral : MonoBehaviour
//if (fishenum != FishTypeEnum.Boss鱼)
ApplyFacingDirection(next);
transform.position = next;
// ⭐ 保留根节点当前 z:3D Boss 在预制体上配置的深度不被擦掉
// (普通鱼 z 一直是 0,行为不变;next 是 Vector2 直接赋值会把 z 强制归 0)
transform.position = new Vector3(next.x, next.y, transform.position.z);
}
public bool isRotate = true;
public bool isNot1 = false;
@@ -682,8 +705,13 @@ public class MonsterContral : MonoBehaviour
_cachedChild = child;
}
Vector3 localPos = Vector3.zero;
localPos.z = depthOffset;
Vector3 localPos = child.localPosition;
// ⭐ x/y 归零摆正模型;z 深度只在显式配置 depthOffset(≠0)时才覆盖,
// 否则保留预制体上设置的 3D 深度(3D Boss 用,之前被强制归零导致深度无效)
localPos.x = 0f;
localPos.y = 0f;
if (depthOffset != 0)
localPos.z = depthOffset;
child.localPosition = localPos;
if (!isRotate) return;
@@ -178,7 +178,8 @@ public class MonsterControl_BossBase : MonsterContral
monsterData.moveLine.Init(bezierData, time);
// ⭐ isMove=true 的 Boss 初始位置设为曲线起点,
// 避免在 moveTime 更新前卡在生成时的 (9999,9999,0)
transform.position = new Vector3(bezierData.start.x, bezierData.start.y, 0);
// z 保留当前值:3D Boss 在预制体上配置的深度不被擦掉
transform.position = new Vector3(bezierData.start.x, bezierData.start.y, transform.position.z);
}
else
{
@@ -190,6 +191,18 @@ public class MonsterControl_BossBase : MonsterContral
// 否则 OnMoveUpdata 不会被调用(OnUpdate 里 isInitialized=false 会 return),moveTime 不自增
isInitialized = true;
ChangeState(CharacterStateType.move);
if (transform.childCount == 0) return;
Transform child = transform.GetChild(0);
Vector3 localPos = child.localPosition;
// ⭐ x/y 归零摆正模型;z 深度只在显式配置 depthOffset(≠0)时才覆盖,
// 否则保留预制体上设置的 3D 深度(3D Boss 用,之前被强制归零导致深度无效)
localPos.x = 0f;
if (depthOffset != 0)
localPos.z = depthOffset;
child.localPosition = localPos;
}
/// <summary>