Search code examples
javascriptgame-physicsbox2dweb

How to detect wether an Object came to sleep at a specific position?


I'm currently writing a small game with box2dweb and I need some direction for this: I'm throwing a Box or Ball and have to hit a specific place and trigger an event when the object that's been thrown isn't moving anymore, "fell asleep" so to say.

What's the proper way / best practice for this?


Solution

  • You could check it's velocity to see if it's moving anymore. Just call GetVelocity() on the body. I believe it returns a b2vec.