Ospho
Ospho

Reputation: 2796

Box2d - Reducing sensitivity of a b2body

Is it possible to reduce the sensitivity of a b2Body's object when its under the influence of a mouse joint?
Basically I have a camera that follows my b2body and the excessive rotation is causing the camera to go abit crazy.
I have attempted using rotation limiting code, which isnt really ideal because it brings strange physics behavior at times.
My rotation limiting code was something like this (pseudo code):

for (b2body *b in _bodies){
    if (b == myhero){
         float ang = myhero->GetAngle();
         if (ang > 35) ang = 35;
         if (ang < -35) ang = -35;
         myhero->setTransform(myhero->GetPosition().x,myhero->GetPosition().y,ang);
    }
 }

Does anyone have any better suggestions? Thanks.

Upvotes: 0

Views: 294

Answers (1)

nash
nash

Reputation: 2181

The mouse-joint to the physics may be exactly what you want. But you don't want your camera to be joined to that as well.

Instead of limiting your hero's freedom of movement, your should limit your camera in following your hero.

Put some easing in the camera. Limit maximum acceleration for movement / rotation. So don't link your body position 1:1 with the camera position.

I'm not sure what style of game you are making, but consider how your want your user to experience it, write up some limits for your camera, and implement them.

Upvotes: 2

Related Questions