瀏覽代碼

Imposter Collision Fixes

My Bad Yo !!!
MackeyK24 8 年之前
父節點
當前提交
a17d142daf
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      src/Physics/babylon.physicsImpostor.ts

+ 1 - 1
src/Physics/babylon.physicsImpostor.ts

@@ -337,13 +337,13 @@ module BABYLON {
 
         //event and body object due to cannon's event-based architecture.
         public onCollide = (e: { body: any }) => {
+            if (!this._onPhysicsCollideCallbacks.length && !this.onCollideEvent) return;
             var otherImpostor = this._physicsEngine.getImpostorWithPhysicsBody(e.body);
             if (otherImpostor) {
                 // Legacy collision detection event support
                 if (this.onCollideEvent) {
                     this.onCollideEvent(this, otherImpostor);
                 }
-                if (!this._onPhysicsCollideCallbacks.length) return;
                 this._onPhysicsCollideCallbacks.filter((obj) => {
                     return obj.otherImpostors.indexOf(otherImpostor) !== -1
                 }).forEach((obj) => {