7
\$\begingroup\$

I'm using Box2D only to check collisions and for no physical simulation. I create bodies (and shapes for them) and use my own code to move them, by setting their velocities and positions every frame. I only fetch collision data from the Box2D world.

Is this a good idea? For example, can it cause undefined behaviour from Box2D? Is there a more performance friendly way of dealing with different shape collision detections?

Do better methods exist for this?

\$\endgroup\$
11
  • \$\begingroup\$ I don't understand. What would you use Box2D for if not physics? What do you mean by "precise shape description"? \$\endgroup\$
    – Anko
    Commented Nov 22, 2014 at 1:05
  • 1
    \$\begingroup\$ @Anko I create shapes for my game objects. Move them and get collisions from Box2D. This is what I mean. \$\endgroup\$
    – Narek
    Commented Nov 22, 2014 at 16:59
  • 8
    \$\begingroup\$ I don't see why this is a off-topic question, it seems pretty valid to me. But it is a duplicate of stackoverflow.com/questions/16309280/…, by the way: don't do it, it is going to look choppy and unstable, since the integrator is part of the collision detection on Box2D, that is, it uses the velocity, torque and acceleration data as part of the guess-work to detect collisions. \$\endgroup\$ Commented Nov 26, 2014 at 3:24
  • 3
    \$\begingroup\$ If you just get collision data and teleport your bodies around with setPosition, Box2D will miss the velocity, acceleration, force, torque and angular speed data, since you're placing the bodies by hand, and not letting Box2D do it's simulation job. For this, Box2D will not be capable of telling your collision with precision, but maybe some frames late, or even with wrong data, since the data missing plays a big part on the collision predicting it uses for dynamic bodies. Your alternative is to use the full simulation on Box2D, or not use it at all. That is, if you want a good game. \$\endgroup\$ Commented Nov 27, 2014 at 22:23
  • 1
    \$\begingroup\$ Thanks. This is actually the answer to my question. I would accept that! \$\endgroup\$
    – Narek
    Commented Nov 28, 2014 at 6:17

0

Browse other questions tagged .