[BUG?] No collision detection with PhysicsBoxCollider

[BUG?] No collision detection with PhysicsBoxCollider

PhysicsBoxCollider is extended from BoxCollider, but method onCollisionEnter() is not invoked on collision. Is this a bug? If not I have to use a PhysicsBoxCollider for physics simulation and a BoxCollider for collision detection?


There are difference listener invoker and also difference register too. If you use physicsBoxCollider here some in sample.

Register code:
cc.director.getPhysicsManager().enabled = true;
cc.director.getPhysicsManager().debugDrawFlags = 0;
Listener Code:
onBeginContact: function (contact, selfCollider, otherCollider) {}
onEndContact: function (contact, selfCollider, otherCollider) {}


Oh, thank you. I will try it now.


I’ve been having the same problem. I’ve turned on both the “enable contact listener” and “bullet” settings on the Rigidbody component and it hasn’t worked. I’ve also tried the above code in this thread without success.


How do you fix this issue? I am using Cocos Creator v1.9. Thanks


i’m using contact listeners extensively and it works nice by checking the “enable contact listeners” and declaring the methods (in Typescript) like so

protected onBeginContact(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void {

protected onEndContact(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void {

can you please post your code/test project?


So this is my code for the collision callbacks below. However, when I added cc.director.getPhysicsManager().enabled = true; to the canvas as a script, collision works, but, the player now falls through the ground and I’m getting a console error. It says: “InvalidStateError: An attempt was made to use an object that is not, or is no longer, usable”

   onBeginContact: function (contact, selfCollider, otherCollider) {
    			this.accel = 0;
    			this.accLeft = false;
    			this.accRight = false;

        if (otherCollider.tag === 0) {
	onEndContact: function (contact, selfCollider, otherCollider) {
		    this.accLeft = true;
			this.accRight = true;