Yanifska Posted May 26, 2015 Share Posted May 26, 2015 Hi there, is there a specific way to remove a constraint like lockConstraint ? Link to comment Share on other sites More sharing options...
valueerror Posted May 26, 2015 Share Posted May 26, 2015 of course.. you just should keep track of your constraint.. usually i store the constraint directly on one of the constrained objects..somesprite.constraint = game.physics.p2.createRevoluteConstraint(somesprite.body, [0,0], someothersprite.body, [0,0], 10000);then i delete it with:game.physics.p2.removeConstraint(somesprite.constraint);somesprite.constraint = null;you could also clear ALL constraints at once:function clearAllConstraints(){ var allConstraints = game.physics.p2.world.constraints.splice(0,game.physics.p2.world.constraints.length); if (allConstraints.length > 0){ for (i=0; i<=allConstraints.length; i++){ game.physics.p2.removeConstraint(allConstraints[i]);} }}note that i use a workaround to get all constraints because the last time i checked the "getConstraints()" function returned "undefined" (i already reported the bug so it's probably fixed by now) Yanifska, DawnPaladin, nimohe and 1 other 4 Link to comment Share on other sites More sharing options...
Recommended Posts