Angle limits and motors are preventing bodies to sleep

Discuss issues specific to the C#/XNA ports of Box2D
Posts: 1
Joined: Sun Nov 29, 2015 7:26 am

Angle limits and motors are preventing bodies to sleep

Postby menionleah » Sun Nov 29, 2015 8:27 am

Aim: I'm developing a turn-based game that heavily relies on Unity 2D physics, which are a port from Box2D. It's important for me that all bodies go to sleep as soon as they stop moving, because I'm waiting for that to start next turn.

Issue: Unfortunately, it happens quite often that bodies never go to sleep. I tried tweaking Physics2D settings for days, thus improving stability and/or performances, but this issue still occurred. I figured out that this problem is related to HingeJoint2D: when they try to enforce a constraint (both angle limits or motor force), they won't allow their connected bodies to sleep.

I also tried to manually set really slow moving bodies to sleep, but (and this sounds quite weird to me) it seems that calling .Sleep() on a body causes other bodies to wake up, thus preventing the whole world to ever be able to fall asleep.

Question: Is anybody facing a similar situation? Any clue or workaround on how to solve it? Thanks!

Return to “C Sharp”

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest