Can explicitly prevent a body from sleeping?
I recently upgraded to the latest chipmunk, and if I enable sleep, my avatar cannot move.... everything else works - he can shoot arrows, etc.... just cant move.
(he moves by applying an impulse and zeroing out velocity every frame - so I think chipmunk thinks he is asleep)
Thanks for any advice....
Avoiding Sleep
-
- Posts: 6
- Joined: Sat May 17, 2008 1:03 pm
- Contact:
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: Avoiding Sleep
There isn't a flag for it no, but you can call cpBodyActivate() when you change parameters on the body.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
-
- Posts: 6
- Joined: Sat May 17, 2008 1:03 pm
- Contact:
Re: Avoiding Sleep
Thanks Scott - That worked perfectly 

- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: Avoiding Sleep
Basically you should call that any time you change a body or constraint parameter when you are using sleep.
<pointless monologue>
I should probably have the setter functions do it for you. I was going to originally, but there isn't an easy way to check if the new value was the same as the old value in the macros. The thought was that if you were setting a force or motor strength each frame to it's full or zero value, that it shouldn't have to continuously wake the object back up. Not that it's expensive to try to wake something up that is not sleeping, but that it prevents the object from sleeping which could be beneficial. I suppose for the rare case where this is useful, you could just wrap the set call to check if the value is actually changing before setting it.
</pointless monologue>
<pointless monologue>
I should probably have the setter functions do it for you. I was going to originally, but there isn't an easy way to check if the new value was the same as the old value in the macros. The thought was that if you were setting a force or motor strength each frame to it's full or zero value, that it shouldn't have to continuously wake the object back up. Not that it's expensive to try to wake something up that is not sleeping, but that it prevents the object from sleeping which could be beneficial. I suppose for the rare case where this is useful, you could just wrap the set call to check if the value is actually changing before setting it.
</pointless monologue>
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Who is online
Users browsing this forum: No registered users and 16 guests