From e4905bcca2a8726427c4db31e52b6b54412f85d4 Mon Sep 17 00:00:00 2001 From: panw Date: Mon, 3 Nov 2025 10:56:32 +0800 Subject: [PATCH] =?UTF-8?q?fix(physics):=20=E5=90=AF=E7=94=A8=E7=89=A9?= =?UTF-8?q?=E7=90=86=E8=B0=83=E8=AF=95=E7=BB=98=E5=88=B6=E5=B9=B6=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E8=8B=B1=E9=9B=84=E7=A2=B0=E6=92=9E=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 启用AABB和质心的物理调试绘制标志,并在HeroViewComp中设置碰撞器组为英雄组 --- assets/script/Main.ts | 4 ++-- assets/script/game/hero/HeroViewComp.ts | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/assets/script/Main.ts b/assets/script/Main.ts index bb5c2a5b..efc4640f 100644 --- a/assets/script/Main.ts +++ b/assets/script/Main.ts @@ -12,9 +12,9 @@ const { ccclass, property } = _decorator; @ccclass('Main') export class Main extends Root { start() { - // PhysicsSystem2D.instance.debugDrawFlags = EPhysics2DDrawFlags.Aabb + PhysicsSystem2D.instance.debugDrawFlags = EPhysics2DDrawFlags.Aabb // |EPhysics2DDrawFlags.Pair - // |EPhysics2DDrawFlags.CenterOfMass + |EPhysics2DDrawFlags.CenterOfMass // |EPhysics2DDrawFlags.Joint // |EPhysics2DDrawFlags.Shape; } diff --git a/assets/script/game/hero/HeroViewComp.ts b/assets/script/game/hero/HeroViewComp.ts index 75045bfd..c9afc700 100644 --- a/assets/script/game/hero/HeroViewComp.ts +++ b/assets/script/game/hero/HeroViewComp.ts @@ -53,7 +53,11 @@ export class HeroViewComp extends CCComp { this.on(GameEvent.FightEnd,this.do_fight_end,this) const collider = this.node.getComponent(BoxCollider2D); this.scheduleOnce(()=>{ - if (collider) collider.enabled = true; // 先禁 + if (collider) { + collider.enabled = true; // 先禁 + collider.group = this.box_group; // 设置为英雄组 + } + },0.1) // let anm = this.node.getChildByName("anm") // anm.setScale(anm.scale.x*0.8,anm.scale.y*0.8);