Box2D is an open-source rigid-body 2D physics simulation library for games, written in C++.

learn more… | top users | synonyms

62
votes
5answers
24k views

Good 2D Platformer Physics [closed]

I have a basic character controller set up for a 2D platformer with Box2D, and I'm starting to tweak it to try to make it feel good. Physics engines have a lot of knobs to tweak, and it's not clear to ...
19
votes
4answers
4k views

Best strategy (tried and tested) for using Box2D in a real-time multiplayer game?

I am currently tackling real-time multiplayer physics updates for a game engine I am writing. My question is how best to use Box2D for networked physics. If I run the simulation on the server, should ...
15
votes
6answers
6k views

Are there any alternative JS ports of Box2D?

I have been thinking about creating a top down 2D car game for HTML5. For my first game I wrote the physics and collisions my self but for this one I would like to use some ready made library. I ...
12
votes
5answers
3k views

2D Rope Collision Detection

I'm wanting to create a rope that can collide with objects like in the following youtube video: 2D Game Physics Rope I'm thinking that you implement the verlet integration which uses points and ...
11
votes
1answer
2k views

Should I write my own physics engine, because of networking integration?

I'm currently developing a top down, realtime, zombie shooter. I'm coding this in Java, using JBox2D as my physics engine. I have been coding the networking this week, and am now up to the physics ...
10
votes
2answers
4k views

Making a character move along a curved slope in a World with gravity

I have seen this game Fancy Pants 2 . And the thing I noticed apart from the physics and beautiful animations is that the character is moving along slopes , even curved slopes. I have little ...
9
votes
1answer
511 views

How do I make a curved surface out of rectangular blocks?

For a Peggle-like game, I want to make blocks that follow a curve, like this: The blocks would then disappear as the ball hits them. I managed to draw some horizontally, but I'm having trouble ...
9
votes
3answers
4k views

Box2D Get Bounding Box of a Body

In Box2D, I was curious if it's possible to get a bounding box of a body already created in the world. So basically, the Body is created, it's interacting with the world and such. And I needed that ...
9
votes
2answers
1k views

How to implement 2d explosions that will cause damage taking into account covers and distance?

How can I implement a 2D explosion in a way that it will cause less damage to characters that hide behind crates or other cover? Ideally damage will depend on the strength of the cover (e.g. metal ...
9
votes
3answers
2k views

How do you do AI path following within a 2d physics engine like farseer/box2d?

I'm in the process of moving a 2d top down game I've been working on into a proper rigid body physics engine like Farseer. Up until now, I had just hacked together my own physics code where needed. ...
8
votes
1answer
3k views

Basic Box2D collision detection

I don't understand how to listen for collisions in Cocos2D/Box2D. Say I have two dynamic circle bodies. One is very small and the other is relatively large. When the small circle collides w/ the ...
8
votes
3answers
361 views

Make fast thing look slow (Box2D)

I'm working on a game that you control a trebuchet to throw balls to the opponent. It's like a game called 'Medieval Siege'. When the trebuchet is swinging its arm, player need to seize the best ...
8
votes
1answer
274 views

In Box2D, how can I get the compression force on a specific body?

I'm using Box2D. As you can see, there are three dynamic bodies connected to each other (think of it as a table from front view). LEG1 and LEG2 are connected to the static body (it's the ground ...
8
votes
1answer
423 views

How can I copy or back-calculate definitions for an entire b2World?

I'm working on a platformer where I'd like to be able to move or copy bodies between multiple Box2D b2Worlds. The desire has cropped up three times now - moving objects between documents in my editor, ...
7
votes
4answers
2k views

How do I make my rain effect look more like rain and less like snowfall?

I am making a game in that game I want a rain effect. I am little bit far from this right now. I am creating the rain effect like below: particleSystem.addParticleInitializer(new ColorInitializer(1, ...
7
votes
2answers
4k views

Is it worth it to use Bullet for 2D physics instead of Box2D for the sake of learning Bullet?

There isn't much more to the question. I'm not concerned about overhead, as I'm sure they are both fine for my purposes. Basically, I am familiar with Box2D concepts because of the Farseer Physics ...
7
votes
6answers
619 views

Physics library internals

I've seen box2d and bullet ports into javascript, but neither of them attracted me particularly, except by source code. It all seemed, after all, quite simple once I looked inside them. But what are ...
7
votes
4answers
1k views

Making a Box2D ball bounce to constant height

I want to create a game like Doodle Jump. I'm using libgdx and Box2d. I needadvice on how to make my ball bounce constantly and with the same height. I've tried setting the ball's body restitution ...
7
votes
6answers
414 views

Determining player.isFalling() through change of y?

I'm currently using Box2D and my character is a bunch of fixtures in Box2D. I was wondering if, to determine if a player is falling, detecting a change in Y position would be appropriate? Are there ...
7
votes
4answers
3k views

Implementing top view physics using box2D

How can top view physics games be done in box2D? One idea I have is to set the linear velocity of an object manually or to alter the linear and angular damping as my object moves over different ...
7
votes
2answers
5k views

Using The Box2D Polygon “Set()” function?

I'm using the Box2D physics engine. And there's a type of shape for box2D called b2PolygonShape. In this class, you can create polygons. There is also a Set() function that takes an array of points ...
7
votes
1answer
775 views

How to simulate feather fall in box2d?

I am working with AndEngine with Box2d extension, but general answer or a concept idea will be appreciated too. I have feather-like objects in a 2D side view world that I want to be part of the ...
7
votes
2answers
2k views

Box 2D Set Origin

I'm trying to set the origin of a box2d shape. By default, a shape rotates around the center. But I'm trying to get it to rotate around the left of the shape. Like a clock for example. I've heard of ...
6
votes
2answers
4k views

how to ignore physics collision of some objects in box2d

I know this sounds silly but I would like some objects to follow physics while others not to collide each other. I tried to achieve them by setting their position exclusively. But then it will ...
6
votes
2answers
640 views

Show path of a body of where it should go after linear impulse is applied

I am making a game with Andengine and Box2D. I have a dynamic body and I apply linear impulse on the body to move it around when the user have touched the screen. Now I want to show the path where ...
6
votes
3answers
4k views

Box2D Check If Point Intersects a Body

Is there a way to check if a point is intersecting a body? For example, lets say there's a body in the world at a position of (100,100). Is there a way to check if a point at (100,100) intersects ...
6
votes
3answers
2k views

Box2D networking

I am trying to make a simple sync between two box2d rooms, where you can drag boxes using the mouse. So every time player clicks (and holds the mousedown) a box, I try send joint parameters to ...
6
votes
1answer
1k views

What causes Box2D revolute joints to separate?

I have created a rag doll using dynamic bodies (rectangles) and simple revolute joints (with lower and upper angles). When my rag doll hits the ground (which is a static body) the bodies seem to ...
6
votes
3answers
7k views

How to remove a box2d body when collision happens?

I’m still new to java and android programming and I am having so much trouble Removing an object when collision happens. I looked around the web and found that I should never handle removing BOX2D ...
6
votes
3answers
5k views

Polygon/Shape definition changes in Box2D 2.1

I was going through a pretty good tutorial on Box2D here, but I ran into a problem when he made a b2PolygonDef, because the tutorials were made in 2.0, and I'm using 2.1. I could download 2.0 I guess, ...
6
votes
1answer
681 views

Farseer Physics: Ways to create a Body?

I want to create something similar to this using farsser and Kinect: https://vimeo.com/33500649 This is my implementation until now: http://www.youtube.com/watch?v=GlIvJRhco4U I have the outline ...
6
votes
1answer
956 views

Generating a physics body for 2D Worms-like Terrain

I wrote a processing sketch that generates hills for a scorched earth clone, like this: I'm trying to figure out how to make this a physics object in libgdx, but I'm having problems figuring out ...
6
votes
2answers
944 views

Scrolling Box2D DebugDraw

I'm developing a game using Box2D (javascript implementation - Box2DWeb), and I would like to know how I can pan the debug draw. I know the usual answer is - don't use debug draw, it's just for ...
6
votes
1answer
127 views

How can I predict player-to-projectile collisions in Box2D?

I'm making a real time shooting game with Box2D as the physics engine. The gameplay is mostly about trajectory, like Angry Birds. I want to make a slow motion effect and move camera to the player when ...
6
votes
1answer
257 views

How do I duplicate a Box2d simulation, mid-simulation?

I want to serialize the state mid-game, send it over the network to an identical computer (same CPU, same OS, same binary), load it there, and have the two games run in tandem doing the exact same ...
6
votes
0answers
282 views

Box2D strange collisions (jitter) on sharp edges [closed]

I'm currently developing 2D side scroll game with Libgdx + Box2D. And I'm facing some problems with ChainShape (the ground) and PolygonShape (the cart body) collisions. Please look at this video: ...
5
votes
2answers
272 views

How can I simulate a floating character in Box2D?

I am creating a jump'n'run game using the Box2D physics engine. The main character should be a robot like creature without legs, floating over the ground powered by a jet engine. The motion should ...
5
votes
2answers
4k views

Box2dWeb and Images

How do I import and attach a PNG or GIF to a shape in Box2dWeb? The best resource I could find online is at: http://www.jeremyhubble.com/box2d.html However, this "tutorial" doesn't give much ...
5
votes
4answers
1k views

How to port a game from IPad to Iphone [closed]

I just finished developing a 2D side scroll game for the IPad using Cocos2d and Box2d. Now we want to make an IPhone 4 version of the game, but I'm still not sure what is the best way to do it. I ...
5
votes
2answers
306 views

Rectangles render with gaps in between them (Box2D)

Right now I create my boxes where 1 meter is 85 pixels. Gravity is 10. And fixtureDef.restitution = 0.1f; fixtureDef.friction = 0.5f; ...
5
votes
2answers
1k views

cocos2d Merging box2d bodies

i'm using cocos2d to build an iphone game. my game currently has two sprites: one for the main character and another for an item i should carry once he gets on him. the main character and the item ...
5
votes
1answer
2k views

How to apply impulse to a body to make it fly away?

I'm playing around with jbox2d and can't really make a body "fly away" as if from an explosion. From what I have found on the net, making the body fly away from the world center (0,0), should have ...
5
votes
1answer
3k views

Box2D Difference Between WorldCenter and Position

So this problem has been brothering for a couple of days now. First off, what is the difference between say Body.getWorldCenter() and Body.getPosition(). I heard that WorldCenter might have to do ...
5
votes
1answer
753 views

How to create multiple balloon bodies in Box2D?

In Box2D, how would I go about making a body that's being lifted by multiple "balloons"? These balloons would have to be able to be destroyed (for example, by a bow and arrow).
5
votes
2answers
2k views

Box2D Raycast - Getting position / angle of edge hit

I'm casting a ray in Box2D using b2World.rayCast how can I get the normal of the wall which was hit? Or better yet - the line start and end points? The information returned is: Fixture (fixture hit, ...
5
votes
2answers
2k views

How to make bird to fly using box2d

I am new to Box2D, I have set gravity to 10. How to make an object fly in space even though the gravity is 10. What are the properties I need to set to make object fly? Is there any different ...
5
votes
3answers
250 views

What could cause a sudden stop in Box2D?

I'm using Box2d for a game, and I have a bug that's driving me nuts. I've simplified the situation down to a square player sliding back and forth frictionlessly on top of a floor composed of a series ...
5
votes
2answers
2k views

How to create an extensible rope in Box2D?

Let's say I'm trying to create a ninja lowering himself down a rope, or pulling himself back up, all whilst he might be swinging from side to side or hit by objects. Basically like ...
5
votes
2answers
2k views

Physics or Time-Based Animation In Corona SDK (iOS) Using Box2D

I am part way through creating a Doodle Jump clone for iOS using Corona SDK. I'm currently using the physics engine (box 2D). It's not a straight clone, but I need the basic principles in place to ...
5
votes
4answers
2k views

Make player to always move along the terrain

I'm working on a 2D platformer side scroller game. I am giving high impulse to player, the player starts moving and if it hits a slope on terrain, it gets a vertical movement and starts to fly over ...