Hi,
I'm having trouble working out the best way to implement multi-layered physics, and I could do with some advice. I want to make something a bit like Paper Moon (http://blurst.com/paper-moon/) in which things can "pop" in and out of the screen. So there might be 3 layers, with the main character and gameplay happening in the middle layer, and a control mechanic for moving bodies between the layers. What Paper Moon doesn't do, that I'd like to, is have stuff interact with each other on more than just the middle layer (so, if you push an enemy into the background, he'll fall off his platform (because it stays in the "mid-ground", but will now be able to interact with other things in the background.
What's the best way to go about doing this in Box2D? I initially thought that I could just create 3 seperate b2Worlds, and step all of them each frame, and when something moves between layers just remove it from one world and add it to the other world... But I don't know how efficient that will be.
I imagine that this sort of thing might be possible using just one b2world, and using collision filtering to flag which bodies are on which layers, but I have no idea where to begin with something like that. For all of Box2D's awesome user-friendliness, I've tried time and time again to understand how the collision filtering works and I find it incomprehensible every time I try.
I'm having trouble working out the best way to implement multi-layered physics, and I could do with some advice. I want to make something a bit like Paper Moon (http://blurst.com/paper-moon/) in which things can "pop" in and out of the screen. So there might be 3 layers, with the main character and gameplay happening in the middle layer, and a control mechanic for moving bodies between the layers. What Paper Moon doesn't do, that I'd like to, is have stuff interact with each other on more than just the middle layer (so, if you push an enemy into the background, he'll fall off his platform (because it stays in the "mid-ground", but will now be able to interact with other things in the background.
What's the best way to go about doing this in Box2D? I initially thought that I could just create 3 seperate b2Worlds, and step all of them each frame, and when something moves between layers just remove it from one world and add it to the other world... But I don't know how efficient that will be.
I imagine that this sort of thing might be possible using just one b2world, and using collision filtering to flag which bodies are on which layers, but I have no idea where to begin with something like that. For all of Box2D's awesome user-friendliness, I've tried time and time again to understand how the collision filtering works and I find it incomprehensible every time I try.