I am trying to make a box2d b2Body
follow my mouse position. This is the code I am using at the moment but it is not performing very well:
deltaPos = mousePos - body->GetPosition();
deltaPos *= k;
body->ApplyForce(deltaPos, b2Vec2(0, 0));
I have tried playing with k
but the body either lags too far behind the mouse or flies round and round the mouse like crazy. Should I be using an exponentiation there instead of multiplication? I am scared of applying too much force and breaking the sim (I suppose I could use a max).
Is there a more straightforward way to do this?