From 5c521287eed80f74a02695a2a5e911563071e9cb Mon Sep 17 00:00:00 2001 From: wassname Date: Fri, 30 Nov 2018 21:28:27 +0800 Subject: [PATCH] make sure it's out body part that's colliding --- js/walker.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/js/walker.js b/js/walker.js index 3b61981..5888b2d 100644 --- a/js/walker.js +++ b/js/walker.js @@ -103,22 +103,18 @@ Walker.prototype.__constructor = function(world) { this.contactListener.BeginContact = function (contact, impulse) { if (contact.m_fixtureA.m_body.m_userData == "floor" | contact.m_fixtureB.m_body.m_userData) { var otherFixture = contact.m_fixtureA.m_body.m_userData == "floor" ? contact.m_fixtureB : contact.m_fixtureA - if (otherFixture.m_body.m_userData == "right_foot") { - // console.log('grip on ' + otherFixture.m_body.m_userData) + if (otherFixture.m_body === self.right_leg.foot) { // TODO let the agent act to grip or not. Only if palm or foot down? self.right_leg.frictionJoint.maxForce = 1000 * self.grips[0] self.right_leg.frictionJoint.maxTorque = 1000 * self.grips[0] - } else if (otherFixture.m_body.m_userData == "left_foot") { - // console.log('grip on ' + otherFixture.m_body.m_userData) + } else if (otherFixture.m_body === self.left_leg.foot) { self.left_leg.frictionJoint.maxForce = 1000 * self.grips[1] self.left_leg.frictionJoint.maxTorque = 1000 * self.grips[1] - } else if (otherFixture.m_body.m_userData == "right_hand") { - // console.log('grip off ' + otherFixture.m_body.m_userData) + } else if (otherFixture.m_body == self.right_arm.hand) { // TODO let the agent act to grip or not self.right_arm.frictionJoint.maxForce = 1000 * self.grips[2] self.right_arm.frictionJoint.maxTorque = 1000 * self.grips[2] - } else if (otherFixture.m_body.m_userData == "left_hand") { - // console.log('grip off ' + otherFixture.m_body.m_userData) + } else if (otherFixture.m_body === self.left_arm.hand) { self.left_arm.frictionJoint.maxForce = 1000 * self.grips[3] self.left_arm.frictionJoint.maxTorque = 1000 * self.grips[3] }