I'm trying to build complex physics shapes. What I want to do is build a large overall shape by connecting multiple smaller shapes. I'm going to joint them all together so that they move as one cohesive unit. How can I tell the physics engine that these individual shapes shouldn't check for collision amongst themselves? Such that the bigger object is able to be collided with, but the individual pieces that make it up aren't colliding with each other?
My second question is akin to this, I think. I have a worms-like terrain: non-uniform destroyable heights. I want the physics to interact with this terrain. What's the best way to do that?
You can add multiple shapes to a single body. They won't collide with eachother.
Box2D doesn't really support destroyable height fields. You will have to fake it by having multiple static bodies representing the terrain. As pieces of the terrain are destroyed you destroy the corresponding bodies.
actually, what do you think would be the best method for a 2d side-scroller worms-like terrain system? An array of rectangle shapes that correspond to the actual pixel heights of the terrain? (pixel wide rectangles, essentially)? Or is there a better way
I expect Box2D would perform quite poorly or even crash with pixel width polygons. Can you approximate your terrain with chunkier polygons?
not really... it's smooth rolling hills. I mean I'm sure there are parts where its flat enough to approximate with just a simply polygon, but for the most part its really hilly and non-uniform.
I think you might need to think outside of the box2d paradigm (pun intended) to get destroyable terrain.
You could keep everything else as a box2d shape, and have the terrain as a bitmap. Then every frame, sample the relevant pixels, and simplify to contacts of some body with no actual shape. People don't expect pixel perfect behaviour for this sort of terrain (unlike polyline heightmaps, imho).
A simple way would be to use TestPoint to determine which pixels are inside a shape, then find every contiguous bunch of pixels inside the shape, and then treat that as a small circle bounding the bunch.
Maybe this is too complicated to implement properly, anyway. It sounds kinda slow for any appreciable amount of objects.
sounds like a game design issue then. Alright, not a problem for what I have in mind.
Hey Erin man, this box2d is amazing. thank you