Questions tagged [box2d]

Box2D is a free open source 2-dimensional physics simulator engine written in C++ by Erin Catto and published under the zlib license

Box2D is a free open source 2-dimensional physics simulator engine written in C++ by Erin Catto and published under the zlib license.

The engine performs constrained rigid body simulation. It can simulate bodies composed of convex polygons, circles, and edge shapes. Bodies are joined together with joints and acted upon by forces. The engine also applies gravity, friction, and restitution.

Ports of Box2D exist for Java, ActionScript, C#, JavaScript, and D.

3289 questions
5
votes
1 answer

Box2D Hierarchical Connection Between Bodies

I have a arbitrarily deep tree structure of bodies in box2d. When a parent body collides with anything, it should move its children along. On the other hand, if the child is moved due to a collision, the parent should not be touched. One body can be…
anlumo
  • 143
  • 2
  • 7
5
votes
2 answers

Diminishing speed in zero gravity box2d world

I am trying to create a dynamic body that orbits around a static body in Box2D. I have a zero-gravity world, and a DistanceJoint that connects the two bodies. I have removed all friction and damping from the bodies and the joint, and am applying an…
Alex Gyoshev
  • 11,929
  • 4
  • 44
  • 74
5
votes
1 answer

Box2d raycast vs AABB query performance

I'm currently trying to improve performance of a game that makes use of box2d physics (actually box2dlights). I have a method that makes several (let's say about 16 to 64) raycasts within an known area. I wonder if it would be a good idea to make an…
Sebastian
  • 5,721
  • 3
  • 43
  • 69
5
votes
1 answer

X velocity slowing down when applying Y Linear Impulse with Box2D

I'm using libgdx and box2d as my physics engine. Right now I just have a very simple box being controlled on a single flat surface: Everything seems to be working well. I control the box with the arrow keys. If I press the right arrow the box will…
spierce7
  • 14,797
  • 13
  • 65
  • 106
5
votes
1 answer

libGDX Stage input handling

I have an Stage class that handles touch input. In the Screen class I set the stage as InputProcessor: stageTest = new StageTest(new ScreenViewport()); Gdx.input.setInputProcessor(stageHUD); But now I want to add a force to an Box2d object always a…
user4959397
5
votes
3 answers

Is Box2D perfectly deterministic?

I'm writing an Android game using LibGDX and Box2D. I'm planning on adding a turn-based multiplayer feature to it. Now, if on both clients I step the Box2D world at the same rate with the same time steps and I start a simulation on both clients with…
AxiomaticNexus
  • 6,190
  • 3
  • 41
  • 61
5
votes
1 answer

How to make billiards in Box2D and prevent balls from getting stuck on the walls?

As a quick overview: I'm trying to make a game of pool using Box2D as a basis. Now my question: How should I set up the billiard balls and edges so that they act normally? The balls sometimes seem to stick to the edges for no apparent reason. …
Ed Marty
  • 39,590
  • 19
  • 103
  • 156
5
votes
2 answers

Only Integrating Box2D collision detection in my 2d engine?

I have integrated box2d in my engine, ( Debug Draw, etc. ) and with a world I can throw in some 2d squares/rectangles etc. I saw this post, where the user is basically not using a world for collision detection, however the user doesn't explain…
Goles
  • 11,599
  • 22
  • 79
  • 140
5
votes
1 answer

Add colors to Box2D objects in Smart Mobile Studio

I want to add colors to dynamic objects in Box2D. It seems like some properties of dynamic objects have to be assigned in the rendering of the scene. I have played around with the Box2D demo but can't figure out how to add properties like colors…
Flemming
  • 694
  • 7
  • 22
5
votes
3 answers

How to change position of a moving body - Box2D

I currently have a body created that is Dynamic and moves at a constant speed with a Vector2(). What I want is for when the body leaves the edge of the screen, to come back from that current point back to its original point instantaneously. How do I…
Mercify
  • 113
  • 3
  • 9
5
votes
3 answers

How to check if a body has almost stopped moving in libgdx + box2d

So, I have a player body + fixture etc, it is essentially a ball that bounces around. I want to detect when it is 'pretty much' finished moving. At the moment I do this: public Boolean isStopped() { return body.getLinearVelocity().x <= 0.3f &&…
Tom Manterfield
  • 6,515
  • 6
  • 36
  • 52
5
votes
2 answers

How to properly delete a box2d body in version: Box2dWeb-2.1.a.3, Box2D_v2.3.1r3? Box2D bug?

Update Since the problem has been found I've also find out that Box2D for web is leaking on every side :/ To show this I made a simple circle moving in a static polygon and here is the result after some time. Notice how the following items are…
Totty.js
  • 15,563
  • 31
  • 103
  • 175
5
votes
1 answer

What is the Sprite Kit equivalent to a Box2D sensor body?

I need to simulate a fan. In Box2D, I do this through the use of a sensor body. I haven't discovered anything in SK that works similarly. I could be wrong. Any suggestions? thanks a lot!
romox
  • 176
  • 1
  • 7
5
votes
2 answers

Actually limiting maximum speed in Box2D

I want to limit maximum speed a body can travel with. The problem is, even if I do something like this answer suggests: /* after applying forces from input for example */ b2Vec2 vel = body->GetLinearVelocity(); float speed =…
Pythagoras of Samos
  • 3,051
  • 5
  • 29
  • 51
5
votes
2 answers

Box2D collision impact calculation

I'm using a standard Box2D ContactListener to listen on collision events. What I want is to calculate the strength of the impact of the collision between Bodies. I've read many different descriptions of how people calculate it. Some use the preSolve…
noone
  • 19,520
  • 5
  • 61
  • 76