Makalele
Makalele

Reputation: 7551

Make physics body in launch game less rotating and more realistic

I'm developing launch-game type game based on box2d physics. When main character is launched, he's getting boosts or get slowed down by some enemies. The problem is how is it moving. When he got more speed he's rotating a looot (very very fast) and I don't like it.. You probably know Burrito Bison game. I wonder how it's done that main character is moving in such great way. He's rotating sometimes, but only a bit. I know I can turn off rotation by just setting isFixedRotation to true, but it looks crappy. I want rotation, but only a bit. I'm also wondering what's best shape for body for a such game. First I had creppy shaped character, then I decide to make it perfect circle, however it was rotating on the floor like a ball, so I came back to something between these two: circle-like, but not perfect circle. Can someone tell me a good way to make my character more realistic (or to be precise to look nicer). I need some advices!

Regards!

Upvotes: 1

Views: 506

Answers (2)

FuzzyBunnySlippers
FuzzyBunnySlippers

Reputation: 3397

You can check the speed of the rotation each frame and "clip" it if it is greater than a certain amount.

For example:

float32 rotVel = body->GetAngularVelocity();
if(rotVel > maxVel)
{
   body->SetAngularVelocity(maxVel);
}
else if(rotVel < -maxVel)
{
   body->SetAngularVelocity(-maxVel);
}

Is this helpful?

Upvotes: 0

ssantos
ssantos

Reputation: 16536

You can play with damping parameters, angularDamping and linearDamping, to slow down movement and rotation.

Damping is used to reduce the world velocity of bodies. Damping is different than friction because friction only occurs with contact. Damping is not a replacement for friction and the two effects should be used together.

Damping parameters should be between 0 and infinity, with 0 meaning no damping, and infinity meaning full damping. Normally you will use a damping value between 0 and 0.1. I generally do not use linear damping because it makes bodies look floaty.

Upvotes: 1

Related Questions