schteppe / p2.js

JavaScript 2D physics library
Other
2.64k stars 330 forks source link

[Q] Disable/Enable body #311

Closed ghost closed 6 years ago

ghost commented 6 years ago

Is there any method to disable body so it will not be simulated like it doesn't exist? And then enable it after some time?

Or we need to delete and recreate it? I think this would be more complicated for making garbage collector friendly code (unnecessary pooling etc..)

Not big deal, but still it would be helpful.

hayesmaker commented 6 years ago

i think you can safely call world.removeBody(body) to remove a body from the physics simulation, and call world.addBody(body) again when needed. (without destroying the body object).

ghost commented 6 years ago

Sounds logical. But I've already changed source and added .present property :D