character controller

I want to have my character interact with the physics world I've set up. I thought at first I might create a dynamic body and put it to sleep, waking it up to jump and when there isn't anything beneath its feet. I'm wondering if I can turn collisions/gravity on and off for a body? Then I thought I might use a static body and just move it around, matching the gravity I set up for the system. This doesn't seem to work, and I think its probably because you can't move static bodies?

So, how should I do this? I'm not going to have it stand on another body; I'm going to detect the collision with the ground myself and tell the body to stop moving immediately. How can I go about this?
Why do you want to do the collision yourself? Doesn't that defeat the purpose of the physics engine? I believe in future versions of Box2D you can have it report a collision but not do anything about it.

Anyways, personally, I'm using a non-static rectangle, with preventRotation enabled. I iterate over the contact list, and check the manifolds for normals to make sure its pointing upwards to enable jumping. I would *not* suggest trying to move static bodies around. You can't turn gravity off for a single body, but you can probably negate the effects of gravity by applying an equal and opposite force every time step.
hrrmm... well I want to handle the collision myself because I have a worms/scorched-earth type terrain... perlin-noise approximated smoothly rolling hills, essentially an array of floats. Currently there isn't a great way to implement this with Box2D that I'm aware of, but Erin told me in another thread that terrain meshes would be supported in 2.1! I'm not sure what that means yet, but... my project is pretty damn large, so I can always go work on another section of it for a good deal of time.

I can make it stop on the terrain just with a simple SetOriginPosition call, it would be nice to turn off calculations until I want to apply gravity again, I can't really complain though.
An array of floats? Forgive me for being totally useless but I'm curious, is it hight mapping? Or is it a float for each pixel? Because I can't understand why you would use an array of floats for the latter.
If I understand you correctly, you are using Box2d to model all the physics in your game, except ground collisions which are obviously difficult to do with convex polygons and circles.

I think a better way to input your custom collisions back into Box2d would be by use of ApplyForce, instead of SetOriginPosition. The difference being that with SetOriginPosition the velocity of the object will build up, which probably leads to odd effects. You'd have to apply larger forces the more something penetrated the ground. Or for even better results, you can go all in and do as I did, and create your own shape type. This is a bit better than just having forces from an external source, as box2d "understands" that you are talking about a solid, so can handle friction, stacking, sleeping etc.

If you are indeed heightmapping with a sample per pixel, I doubt the upcoming linemesh solutions will help you. In any case, it's not wise to start a large project on the hope of future features solving your problems.
riddly you're absolutely correct an array of floats is retarded for the pixel heights i'm representing, thank you

damn, I'd like to find a minimal solution to this problem... creating my own shape still requires convex shapes, right? I'm having trouble negating the effects of gravity with ApplyForce so perfectly as to simulate ground,
Ok, maybe ApplyForce was a bad idea. at least set the velocity appropriately while using SetOriginPos.

Technically, you don't need convexity to simulate shapes. Nor is writing a bad shape too hard, I found most of the difficulty came from eliminating odd cases and reducing tunneling as much as possible, which you can probably avoid in your terrain design. If you're using the 2.0 version, the algorithms for CCD expect convex shapes for determining separating distance, but I have a suspicion that you can just lie and say very far away and it will effectively just reduce the CCD code to normal collisions, which should again work fine for terrain that extends arbitrarily deep.

Or you could go the other way, and treat the terrain as a lot of trapeziums, and have a mini-broadphase for determining which ones to test.

I'm sorry, I'm just ranting by now, this is all probably too much work for what you're looking for. It's just a question that I've been thinking about too, and thought I'd share.
Have you tried applyimpulse?
First of all, the problem now stands as this: I want to have physics objects interact with my worms/scorched-earth 2d terrain (side-heightmap, smooth rolling perlin hills)

I've been thinking a lot about this, and I've decided that I have two options for how to handle this. Either I can test (basically hit-box testing) any object that has the chance to collide with the terrain, and completely freeze its motion / kill its inertia as soon as I detect a collision (and move the object to the exact spot on the terrain it should rest at). The problems with this: I have to keep track of all objects to test, I have to define a number of collision points to test for intersection, which means I either surround the object in collision points or disable rotation of the object. (and unless i surround it with a lot of points, chances are there will be plenty of possible rotations that have corners poking through the terrain. better(?) to just disable rotation of the body).

The other option is to use the upcoming line segment stuff and build an approximation of the terrain. The disadvantage to this is that it requires more work on the physics engine and doesn't follow my terrain exactly. Furthermore the character itself should just run along the terrain at a set speed; it doesn't really need any more physics interaction besides the spot of intersection with the ground. Other objects, however, I would like to have fall on the ground.

I'm split between these two options. Anyone want to weigh in with an opinion?
I use this code and everything is ok:

body.ApplyForce(new b2Vec2(- gravity.x * body.GetMass(), - gravity.y * body.GetMass()), body.GetWorldCenter());

Original thread: https://box2d.org/forum/viewtopic.php?t=325