Issleepingallowed = False Recommended?

I think I’m going to need this.   I have static objects in my game that hold dynamic objects of various sizes and densities. When the static object is destroyed, I want the dynamic objects to fall, but it looks like unless I set isSleepingAllowed on my dynamic objects to false, they won’t fall all the time.   Some of the smaller ones never fall.

I guess I’ll have to keep an eye on performance, but is that what this property is for?

Hi @davemikesell,

Yes, this is essentially what the property is for. By default, Box2D bodies will “sleep” after a few seconds of inactivity, as a performance-increasing feature. If you have “hybrid” view turned on in the physics engine, you’ll see it happen (they turn grey). So yes, you can override this by setting that property to false, but as you guessed, keep a careful eye on performance. I don’t think you’ll have an issue unless there are hundreds of these objects piled upon each other, but it’s wise to be mindful of it.

Regards,

Brent

Awesome, thanks.   This is one of my busier levels and it is working fine (even though the ice cube stutters in the video a bit, at least on my browser, it doesn’t in the Simulator).   Haven’t tested on a device yet, though, since making the change.

http://mikesellsoftware.com/OnTheRocks.mov

Hi @davemikesell,

Yes, this is essentially what the property is for. By default, Box2D bodies will “sleep” after a few seconds of inactivity, as a performance-increasing feature. If you have “hybrid” view turned on in the physics engine, you’ll see it happen (they turn grey). So yes, you can override this by setting that property to false, but as you guessed, keep a careful eye on performance. I don’t think you’ll have an issue unless there are hundreds of these objects piled upon each other, but it’s wise to be mindful of it.

Regards,

Brent

Awesome, thanks.   This is one of my busier levels and it is working fine (even though the ice cube stutters in the video a bit, at least on my browser, it doesn’t in the Simulator).   Haven’t tested on a device yet, though, since making the change.

http://mikesellsoftware.com/OnTheRocks.mov