# Tag Info

0

It seems that box2d recently changed the way they manage userData. They went from storing void pointers to storing an actual object. So it may explain why you see tutorials around that "do no work" with a more recent version of Box2d. This part of the official documentation illustrates how this should be done now, however it lacks an important ...

1

You can decide to measure your game in cm instead of m. So you'll take a 1.0 unit of distance inside your Box2D world and interpret it as 1.0 cm. A velocity of 1.0 you'll then interpret as 1.0 $\frac {cm} s$ = 0.01 $\frac m s$. A force of 1.0 you'll interpret as 1.0 $\frac {kg \cdot cm} {s^2}$ = 0.01 $N$. To fix the "gravity too slow" ...

1

When I first used box2d I quickly reached the 16 bits limit :-) Then I found a solution: you don't need to use all 16 bits, you need to categorize your objects. For example, you have some grounds and solid platforms, you put them in the SOLID category. You have many enemies, you put them in the ENEMY category. ... An enemy is an enemy regardless of its ...

0

If I'm not mistaken, Box2D also has the ability to store and simulate multiple independent Worlds. So you could have one world for above-ground and a separate world for below ground, and transition objects from one world to the other at tunnel entrances/exits. This effectively means creating a new physics body for them in the new world, and destroying/...

0

Improved the code thanks to @Sacha's clues. if (Game::gameplay_timer_.milliseconds() - launch_time_ > thrust_time_) { delta_.x += SDL_sinf(body_->GetAngle()) * speed_ * delta_time; delta_.y += -SDL_cosf(body_->GetAngle()) * speed_ * delta_time; body_->ApplyLinearImpulseToCenter({delta_.x, delta_.y}, true); } Now the projectile rotates and ...

1

Your update method accelerates the rocket along the direction of its velocity vector (as returned by body_->GetLinearVelocity) but it should accelerate it along the direction it's facing. Currently, there's nothing in the update method that can change the rocket's velocity vector orientation. Box2D allows you to get the current world angle of your body ...

Top 50 recent answers are included