momijigari
momijigari

Reputation: 1598

Nape physics. How to listen to SLEEP event of the space/world?

How should I set a single callback which would trigger when there is no motion in the Space of Nape, when each body "goes to sleep"? I couldn't find any proper solution for this, but I guess this is a must-have for a physics engine. Thank you.

Upvotes: 1

Views: 162

Answers (1)

Marcela
Marcela

Reputation: 3738

You could check space.liveBodies.length on tick (wherever you're calling space.step()).

When it reaches 0, then all bodies are sleeping.

Upvotes: 2

Related Questions