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

learn more… | top users | synonyms

58
votes
5answers
21k 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 ...
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 ...
3
votes
5answers
8k views

What is the proper way to remove a box2d body from the world in libgdx?

I'm wondering how to remove the body from the world, because I found an error when I tried. I found following error. java: ...
6
votes
2answers
541 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 ...
2
votes
1answer
134 views

Using Box2D for range detection?

I have two entities. One has a sword, one has a bow and arrow. When the bow entity is 100 units away, he needs to begin attacking. Likewise, when the sword entity is 10 units away, he needs to begin ...
6
votes
3answers
4k 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, ...
8
votes
1answer
415 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, ...
6
votes
2answers
3k 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 ...
5
votes
1answer
492 views

box2d with lines

I have a very simple platform game builder and I've specified the ceilings, walls and floor as line segments. A line has a winding, or normal; you can determine the direction that a line should be ...
3
votes
1answer
278 views

How to implement server side physics?

I am working on 2-player 2d sidescroller. How should I implement the physics on the server? Use one world for every game or use a big world in which I add every 2 player that start a game? I have ...
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 ...
8
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. ...
3
votes
1answer
1k views

Box2D platformer movement. Are joints a good idea?

So i smashed my brains trying to make my character move. As i wanted later in the game to add explosions and bullets it wasn't a good idea to mess with the velocity and the forces/impulses didn't work ...
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 ...
3
votes
2answers
1k views

When and how should I apply forces in a Cocos2D + Box2D game?

I have some small circles just rolling across the bottom of the screen in my Cocos2D/Box2D iOS app. The bodies are dynamic... so I make them roll by applying a horizontal force to the center of mass ...
3
votes
3answers
459 views

Semi Fixed-timestep ported to javascript

In Gaffer's "Fix Your Timestep!" article, the author explains how to free your physics' loop from the paint one. Here is the final code, written in C: double t = 0.0; const double dt = 0.01; double ...
4
votes
1answer
448 views

Cocos2d: Tongue effect like in Munch Time

I'm wanting to do a tongue effect for my character like the one in Munch Time( shown in pic ). The player does some action and his tongue attaches to the nearest platform. I'm thinking this is ...
2
votes
1answer
217 views

Camera scrolling and game boundaries

I am making a platformer game in JBox2D and LWJGL that has a scrolling camera, but I have hit a wall with the boundaries of the camera. Essentially what I have right now is a Box2D world that is ...
2
votes
1answer
1k views

Stopping on a slope in Box2d

I am creating a simple platformer using Box2d. I've implemented a variant of the technique described here. To make the player character move more 'platformer-like' I want him to stop on (shallow) ...
2
votes
2answers
835 views

Simple 2D Flight Physics with Box2D

I'm trying to build a simple side scroller with an airplane being the player. As such, I want to build simple flight controls with simple but realistic-feeling physics. I'm making use of cocos2D and ...
0
votes
1answer
381 views

Why might a body suddenly stop while moving on continue platform?

I have a 32x32 sprite and I make some to be platform like this for (int i = 0; i < 15; i++) { attachChild(new Ground(32 * i, 200, regPlatform, vertexBufferObjectManager, physicsWorld)); } ...
7
votes
2answers
1k 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
3answers
6k 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 ...
4
votes
1answer
396 views

Collision Filtering in Box2D

I have four bodies in my Box2D World. Each are polygon shape, with some physics parameters. Now when the game start, I need one of the bodies from the World (BodyA) to not be allowed to collide with ...
4
votes
2answers
320 views

Detecting a ledge in Box2D [duplicate]

Possible Duplicate: Detect Open Space in Farseer How do I detect ledges? I'm making a 2D platformer with Box2D. The player needs to be able to grab onto a ledge and pull him/herself up. ...
4
votes
3answers
629 views

IndexOutOfRangeException on World.Step after enabling/disabling a Farseer physics body?

Earlier, I posted a question asking how to swap fixtures on the fly in a 2D side-scroller using Farseer Physics Engine. The ultimate goal being that the player's physical body changes when the player ...
3
votes
3answers
492 views

How to make Box2D bodies automatically return to a initial rotation

I have two long Box2D bodies, that can collide while moving one of them around with MouseJoint. I want them to try to hold their position and rotation. Blue body is moved using MouseJoint (yellow) ...
3
votes
3answers
317 views

Libgdx body passing through block then fall on it

I'm using libgdx and its physic engine Box2d. My question is : how could I make my box2d body go through a block , ignore the first collison than make the block active so the ball can fall onto it. A ...
2
votes
1answer
396 views

How to make a character in a Box2D world jump faster?

I have a question about using Box2D to simulate a physics-platformer. I manage to make the character move to the right and left, and jumping as well. However, jumping seems extremely slow when ...
2
votes
1answer
372 views

How do I make a rope from point A to B in Box2D?

I need to make a rope (preferably not elastic) from one point to the next in Box2D. If it helps, I'm trying to develop one of those 2D Spiderman games, like this: ...
1
vote
3answers
2k views

What is the Box2D coordinates system?

I know that for Box2d I need to translate pixels to meters which is easy peasy. However my problem is what is the orientation of Box2D coordinates system? Is this the same as screen one (right += x, ...
1
vote
3answers
878 views

Unable to find good parameters for behavior of a puck in Farseer

EDIT: I have tried all kinds of variations now. The last one was to adjust the linear velocity in each step: newVel = oldVel * 0.9f - all of this including your proposals kind of work, however in the ...
1
vote
1answer
1k views

Making an object swing from one rope to another

I am trying to make a Tarzan like game with Cocos2D and Box2D. I am having issues with the physics - making an object swing from one rope to another. I am not really sure how to do this. Could anyone ...
1
vote
1answer
2k views

How can I cancel a contact in a b2ContactListener?

To know when contacts happen we can derive from b2ContactListener and implement our own solution which is great. I'm wondering is there anyway we can cancel a contact, that is to say when we hit begin ...
1
vote
2answers
2k views

Box2D Platform body not moving player body along with it

I am creating a game using Box2D (Javascript implementation) - and I added the ability to have a static platform, that is moved along an axis as a function of a sine. My problem is when the player ...
0
votes
2answers
79 views

Floating point precision issue with Box2D

I'm using Box2D and I am putting edge tiles as b2Bodies so that the tile world can have physics: The problem is that there are 3 b2_kinematic bodies under the player right beside each other. Every ...
0
votes
1answer
462 views

AS3: limit objects to stage width?

I want to limit the creation of objects acording to the stage width. My method is the following: for (var i:int = 0; i<7; i++){ If I put something like this, it won't work for (var i:int = ...