节点销毁,碰撞任在继续

A与B两个节点碰撞,A节点被攻击销毁,B节点离开,可是两个节点的持续碰撞回调还在继续

Collider1.on(‘onTriggerEnter’, this.onTrigger, this);

Collider1.on(‘onTriggerExit’, this.onTrigger1, this);

Collider1.on(‘onTriggerStay’, this.onTrigger2, this);

private onTrigger(event: ITriggerEvent) {//碰撞开始
if (event.otherCollider.node.name == “ant0” || this.colliderName == “ant1”) {

        this.animator.play("attack")

        log("碰撞ant1")

    }

    if (event.otherCollider.node.name == "sce14") {

        this.animator.play("attack")

        log("碰撞sce14")

    }

}

private onTrigger1(event: ITriggerEvent) {//碰撞结束

    if (event.otherCollider.node.name == "ant0" || this.colliderName == "ant1") {

        log("离开")
        Tween.stopAllByTarget(this.node)
        let anim = this.node.getComponent("Enemy")!.animator
        anim.play("run")
        tween(this.node)
            .to(2, { position: new Vec3(0, 0, 0) }, {

                easing: 'linear', onComplete: () => {
                    this.animator.play("attack")

                }
            })
            .union()
            .repeat(1)
            .start();
    }

}

public onTrigger2(event: ITriggerEvent) {//碰撞持续

    if (event.otherCollider.node.name == "ant0" || this.colliderName == "ant1") {

        if (this.animator.getState("attack").isPlaying === true) {

            this.animator.on('lastframe', this.antFinished, this);

        } else {

            this.animator.off('lastframe', this.antFinished, this);

        }

    }

    if (event.otherCollider.node.name == "sce14") {

        if (this.animator.getState("attack").isPlaying === true) {

            this.animator.on('lastframe', this.onFinished, this);

        } else {

            this.animator.off('lastframe', this.onFinished, this);

        }

    }

}

我记得是碰撞和节点是独立的个体,虽然其他的组件会因节点失效而失效,但是碰撞应该是不会的

selfCollider.enable = false,直接屏蔽碰撞

请教下,(运用了碰撞组件)。比如有3个弓箭相隔极短时间内从5个敌人里随机挑选打,可能3个弓箭都打同一个敌人,那么当第2只箭的时候敌人已经死了(destroy),那么第三只箭就要射出屏幕,那么在判断第三支箭的时候就要写cc.isValid(敌人)。再有一些其他的逻辑,凡是涉及到敌人的都要cc.isValid(敌人),是不是有些麻烦了。。

一般有个状态吧,已死亡die=true,死了就不进行判断了。