Hi,
I set my space->sleepTimeThreshold to, say 1 second, and I've got a couple of sensors( 1 body + 1 shape) that I have sitting in one place, and when I pass another (1 body + 1 shape) over it, they don't wake up, or cause a collision. I see that the step checks objects for their kinetic energy before deciding whether to have them sleep or activate, but I'm wondering if there's a way to have the sensors sleep, but also 'look' for collisions? Does that make sense? I'm basically asking if there is a way to have a stationary sensor be woken up by another (moving) body/shape?
Of course, it works when I don't set the sleepTimeThreshold, and everything stays awake. Is there any way to have my cake and eat it too?
Thanks,
Mark
space sleeping and shape->sensor
-
- Posts: 6
- Joined: Thu Aug 05, 2010 1:52 am
- Contact:
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: space sleeping and shape->sensor
The sensor callbacks should still function though right? In that case you can just call cpBodyActivate() in a post step callback. Thinking about it now, I'm not sure if it's safe to reactivate bodies from a callback, I should double check and document that.
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: Thu Aug 05, 2010 1:52 am
- Contact:
Re: space sleeping and shape->sensor
Scott,
Oooh, thank you, I missed that when I was perusing your code. I'm, of course, not using your engine correctly. Currently I've got two types of sensors that I move manually, so BOTH of them were sleeping, while I was manually moving them around, which was, of course, not even calling 'begin' when the two shapes overlapped. So now, when I manually move the shape, I simply call cpBodyActivate, which allows it to trigger the 'begin', and I can activate my other sensor. I'll figure out a better, even 'right' way to do it later, but for now, it works. Thank you!
The only thing is, I'm finding that with this method, begin and preSolve are called every step while the sensors are touching. I'm getting around that by setting my own state var for the sensors, but .. would anyone have any suggestions for moving the physics bodies manually and keeping it awake based on my movement(basically according to sprite movement)? Currently I'm doing this each step:
-Mark
Oooh, thank you, I missed that when I was perusing your code. I'm, of course, not using your engine correctly. Currently I've got two types of sensors that I move manually, so BOTH of them were sleeping, while I was manually moving them around, which was, of course, not even calling 'begin' when the two shapes overlapped. So now, when I manually move the shape, I simply call cpBodyActivate, which allows it to trigger the 'begin', and I can activate my other sensor. I'll figure out a better, even 'right' way to do it later, but for now, it works. Thank you!
The only thing is, I'm finding that with this method, begin and preSolve are called every step while the sensors are touching. I'm getting around that by setting my own state var for the sensors, but .. would anyone have any suggestions for moving the physics bodies manually and keeping it awake based on my movement(basically according to sprite movement)? Currently I'm doing this each step:
Code: Select all
cpBodySetPos(body, sprite.position);
cpBodySetAngle(body, RADS(sprite.rotation) );
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: space sleeping and shape->sensor
Hrm. Begin should not be getting called each time. I'll have to look into that.
If you want it to only wake up when you move the shape, you should check if the new position is the same as the old position first.
If you want it to only wake up when you move the shape, you should check if the new position is the same as the old position first.
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/
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: space sleeping and shape->sensor
Sorry about the long delay, but this should be fixed now. (See http://www.slembcke.net/forums/viewtopic.php?f=1&t=1163 for more info)
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: Thu Aug 05, 2010 1:52 am
- Contact:
Re: space sleeping and shape->sensor
Scott,
Just to confirm, that seems to have fixed my issue with the _begin callback getting repeatedly called even after rejecting.
theMan->you . Thank you!
-Mark
Just to confirm, that seems to have fixed my issue with the _begin callback getting repeatedly called even after rejecting.
theMan->you . Thank you!
-Mark
Who is online
Users browsing this forum: Bing [Bot] and 13 guests