From 4a6f19ae8b40dd09120c020ed98b7f71cccb1d02 Mon Sep 17 00:00:00 2001 From: panw Date: Wed, 8 Apr 2026 10:05:56 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=80=AA=E7=89=A9):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=AF=B9=E8=B1=A1=E6=B1=A0=E5=A4=8D=E7=94=A8=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E6=80=AA=E7=89=A9=E6=97=A0=E9=99=90=E6=94=BE=E5=A4=A7=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 记录预制体初始缩放值,避免重复乘算 --- assets/script/game/hero/Mon.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/assets/script/game/hero/Mon.ts b/assets/script/game/hero/Mon.ts index 9f1002c4..6f8bfd5d 100644 --- a/assets/script/game/hero/Mon.ts +++ b/assets/script/game/hero/Mon.ts @@ -136,6 +136,8 @@ export class Monster extends ecs.Entity { if (!node) { var prefab: Prefab = oops.res.get(path, Prefab)!; node = instantiate(prefab); + // 记录预制体的初始缩放值,防止对象池复用时累乘导致无限变大 + (node as any)._baseScale = node.scale.clone(); } // 统一挂到实体显示层 HERO 节点下 @@ -147,7 +149,8 @@ export class Monster extends ecs.Entity { collider.enabled = false; } - node.setScale(size*node.scale.x,size*node.scale.y); + let baseScale = (node as any)._baseScale || v3(1, 1, 1); + node.setScale(size * baseScale.x, size * baseScale.y); node.setPosition(pos) const model = this.get(HeroAttrsComp); // 从配置表获取怪物静态数据