Hi, this is quite possibly a very ignorant question - as I'm fairly new to Box2d. I have a game with the following setup -
1) A region (sensor)
2) An actor
The actor "enters" the region by detecting contacts with it, and "leaves" the region when all contacts with that region are ended.
There's code elsewhere that can check if an Actor is within a region - returning true/false. This all works fine except for the following scenario.
1) Actor enters the region
2) Actor changes animation while inside the region
When this happens, we're destroying the existing contacts and the existing body and creating a new one for the new animation. What I want to happen is for the contacts to be immediately reevaluated (ideally just for the new fixtures, not everything in the world) to detect that the Actor is still in the region. What does happen is that it has to wait for the next world step. So if the other code is checking for an Actor being in the region -- it will return false for that 1 frame before it detects it as being back in.
What's the best way to go about doing this? Again - this is probably a stupid question, but what are the implications of calling world.step with a first parameter of 0, just to reevalute the contacts? I'm assuming that's a very bad idea.
Thanks,
Greg
edit: forgot to mention that the "region" can be a circle or polygon shape. So just checking if the bounding boxes overlap would not be enough.
1) A region (sensor)
2) An actor
The actor "enters" the region by detecting contacts with it, and "leaves" the region when all contacts with that region are ended.
There's code elsewhere that can check if an Actor is within a region - returning true/false. This all works fine except for the following scenario.
1) Actor enters the region
2) Actor changes animation while inside the region
When this happens, we're destroying the existing contacts and the existing body and creating a new one for the new animation. What I want to happen is for the contacts to be immediately reevaluated (ideally just for the new fixtures, not everything in the world) to detect that the Actor is still in the region. What does happen is that it has to wait for the next world step. So if the other code is checking for an Actor being in the region -- it will return false for that 1 frame before it detects it as being back in.
What's the best way to go about doing this? Again - this is probably a stupid question, but what are the implications of calling world.step with a first parameter of 0, just to reevalute the contacts? I'm assuming that's a very bad idea.
Thanks,
Greg
edit: forgot to mention that the "region" can be a circle or polygon shape. So just checking if the bounding boxes overlap would not be enough.