Jump to content

P2 removeSpring doesn't work


Recommended Posts

I've posted on this before but thought I'd solved it.  I'm trying to add pairs of objects joined by springs (p2.js) which I'd like to be able to unjoin when required without the destruction of the sprites and their bodies.  I can add the springs but nothing I've tried to remove them has worked.  The best I've done is get them all to go or none to go!


I'm using this line to add the spring.

  this.spr1 = this.game.physics.p2.createSpring(b1.body, b2.body, 150, 0.15, 0.05);
b1 and b2 are both sprites with p2 physics enabled.
I've tried both of these lines to remove it and many, many more combinations and methods but to no avail.
         this.game.physics.p2.world.removeSpring(this.spr1);         this.game.physics.p2.removeSpring(this.spr1);
Can anybody give me the line to remove a spring once created?  I'd be most grateful.
Link to comment
Share on other sites


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...