# Tagged Questions

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

5k views

### How to set a body to a specific position using Andengine

I'm developing a game with a single player and multiplayer mode. Lets say I have walls (static bodies), vehicles (dynamic bodies) and bullets (dynamic bodies). It works fine to control my own vehicle ...
182 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 ...
242 views

### Box2D + Citrus Engine - Proper Pong Paddles

I am creating a pong clone for my first Citrus Engine project using Box2D. I've tried two types of paddles, both do not fully work. 1) Paddle is a dynamic body with a restitution of 1.0 and friction ...
520 views

### How do I prevent other dynamic bodies from affecting the player's velocity with Box2D?

I'm working on my player object for my game. PhysicsBodyDef def; def.fixedRotation = true; def.density = 1.0f; def.position = Vec2(200.0f, 200.0f); def.isDynamic = true; def.size = Vec2(50.0f,200.0f)...
413 views

### Using Box2D / Physics with Tiles?

Here is my issue. I currently have Box2D setup and working. But, it works with my Entity system. So I can create static objects and dynamic moving ones, and they simulate fine. However, my world is ...
617 views

### How can I get the force of a collision in Love2D?

Is it possible to get the force of a collision between two objects in Love2D/Box2D? If so, how?
1k views

### Communication between Box2D and libGDX Stage (Scene2D) running in separate threads

I'm making a physics based 2D game using libGDX and Box2D. I want to move the execution of the simulation out of render thread. I use immutable messages and the BlockingQueue to pass the information ...
293 views

### How to make box2d bodies block each other but not push each other?

I want to use box2D to create a movement system for an RTS game. How can I make bodies block the movement of other bodies while preventing these bodies from pushing each other?
115 views

### Create body on a sprite (box2D)

I'm quite experimented in objective C, but now i'm tried cocos2D and his features. I need to add a body on a spritesheet (if possible on a classic 'UIImageView'), in order to detect collisions after. ...
11k views

### How can I convert a tilemap to a Box2D world?

I want to use Box2D physics and lighting with a .tmx map. How can I "convert" a tilemap to Box2D world? My basic idea is to go through the tiles on the map and create an object for them in Box2D. I'm ...
92 views

### How can I smoothly rotate a joint to an angle? [duplicate]

I would like to set the speed of my Box2D revolute joint on every update such that it rotates to a desired angle and stops. It should ramp down as its angle approaches the desired angle. My first ...
224 views

### Farseer - Difference between Position, GetLocalVector, and GetWorldVector

I have used Box2D extensively, and am used to just calling body.GetPosition(). But Farseer does not have this. Instead it has a property Position, as well as methods GetLocalVector and GetWorldVector. ...
643 views

### libgdx default saving mechanism for box2d world

I want to save my game in libgdx, and I have no problem using Kryo to save everything, except the box2d Worlds and the RayHandlers from box2dlights - these are not Serializable and do not have default ...
61 views

### Check every body's position and delete or not (box2d performance specific)

I have a simple game with a platform (a ground that's not infinitely long). During the game I have about 10-30 balls on average that'll fall off the platform. There's gravity so I think they'll keep ...
281 views

### How to spawn an object on collision in box2d + love2d?

I'm trying spawn collidable debris from a ship when it explodes in love2d/box2d, however, World:isLocked() is true when collision callbacks are called: This will return true inside the callbacks ...
645 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 ...
165 views

### Collision function calls before colliding

My Box2D contact listener class is calling post solve and beginning the contact function before colliding? This is causing my object to bounce back before hitting the ground. What could be causing ...
1k views

### How to find collision detection side between two objects?

I am using box2D and I have two objects, one is bouncy ball and the other one is block. I'd like to find which side of the block is collided with, so I can only make the ball bounce when it hits the ...
37 views

### 2D collision beetween a sprite and an array of sprites [duplicate]

I am creating a simple Android jumper (think Doodle Jump or Abduction) using libGDX so I can get started in game programming. My problem is that I need to figure out a way to check for collision ...
492 views

### Syncing world in a multiplayer

I have been working on a client-server architecture for my multiplayer game. The server is used for communication between Clients. There is no cheat control because I trusting all clients :) I don't ...
46 views

### Using texture() in combination with JBox2D

I'm getting some trouble using the texture() method inside beginShape()/endShape() clause. In the display()-method of my class TowerElement (a bar which is DYNAMIC), I draw the object like following:...
106 views

### Box2D relations

As far as I know, the unit in Box2D is meters. When I use Box2D in Processing with JBox2D, I set the "world size" as the window size specified in the setup(). Now I'm wondering if there is any ...
891 views

### Running multiple box2D world objects on a server

I'm creating a multiplayer game using LibGdx (with Box2d) and Kryonet. Since this is the first time I work on multiplayer games, I read a bit about server - client implementations, and it turns out ...
77 views

### Need to join 2 bodies via weld joint but not on center of mass

I have successfully join 2 bodies via weld joint , but my problem is I want to join corners of bodies not on centre of mass. Is there any way to achieve this? Above image consist 3 polygon body that ...
273 views

### JBox2D Polygon Collisions Acting Strange

I have been playing around with JBox2D and Slick2D and made a little demo with a ground object, a box object, and two different polygons. The problem I am facing is that the collision-detection for ...
1k views

### Movement of body after applying weld joint

I have two rectangular bodies. I've applied Weldjoint successfully on these bodies. I want to move that joined body by applying linear impulse. After weld joint, these two bodies becomes single body ...
3k views

### coloring box2d body in LibGDX

I want to color polygon of box2d in LibGDX. Found below useful class for that. http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/glutils/ShapeRenderer.html But, it is not ...
1k views

### Box2d making a body follow the mouse accurately

I am trying to make a box2d b2Body follow my mouse position. This is the code I am using at the moment but it is not performing very well: deltaPos = mousePos - body->GetPosition(); deltaPos *= k; ...
143 views

### Move background with the player location

I want to move background with player location in ios . I have implemented the infinite parallax background by using the CCParallax class but i don't need it. I want to do something similar to this ...
1k views

### box2d raycast filter category

I am trying to filter a category in my ray casting (jBox2D within libGDX), which should return the closest object that does not belong to the category LEVEL0. I've tried a plethora of approaches, but ...
92 views

### Getting a sprite from multiple sprites for right material pattern

Not sure how accurate the question was but I'll put it this way. I'm developing a game where player will construct his/her own stuff, like bridge, building etc. using cocos2d-iphone and Box2D. First ...
2k 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) ...
678 views

### Box2D Static-Dynamic body joint eliminates collisions

I have a static body A, and a dynamic body B, and a dynamic body C. A is filtered to not collide with anything, B and C collide with each other. I wish to create a joint between B and A. When I ...
574 views

### Remove a body when touched in LibGDX(Box2D)

I am using LibGDX to create a new project. What i am trying to do is, i load bodies from a tmx file into levels which works fine. The bodies also has a sprite with them. The problem is, is i would ...
647 views

### How do I make a Box2D object that makes objects passing through it slower?

I wish to have a sort of "slow motion" or "slow down" effect on a players character when they walk in a mud area, usually the character velocity is 3f constant in any one direction. The problem is I ...
455 views

### Making a 2D TMX tile map

Should there be a specific link between the characters height as well as the tile size for the tile maps? That is if a tile is 32x32 does that mean that a character sprite has to be the same size? ...
104 views

### How to reduce the time it takes to speed up an object?

I have a body that I am applying a force to every step. However, I it takes a significant amount of time for it to speed up, which I do not want. Is there some value I can adjust to help with this?
548 views

### Getting body position

I am using BodyA.getPosition().x and BodyA.getPosition().y to get the x and y vector of a body location so i may attach some text above its head, but the log of that position prints out something like ...
111 views

### Encapsulating Box2D C++ two virtually the same functions

I have two functions that are virtually the same with a few small differences in code, one to create a static body and one to create a dynamic body, however if I call both of them it results in a ...
559 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 ...
614 views

### Showing trajectory indicator

From the image you can see that the ball fired on the left that fire behind it, does not match the calculated trajectory. Im drawing the ball trajectory using an equation from a SO question, this is ...
135 views

### libgdx fixture is giving unresponsive error

need some support. I am novice in libgdx game engine. Below is my code package com.game.box2d.fruitcart; import com.badlogic.gdx.Game; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.audio....
463 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: http:...
230 views

### Box2D Qt wrong collisions

I am working on a simple Box2D game (with Qt), but my objects don't collide correctly: As you can see on the picture, objects try to go through each other and slide over. My b2World: b2Vec2 ...
5k views

### Libgdx explain steps for beginner to create and use image as a box2d body [closed]

I am basically from corona background and new to LibGdx , familiar with stage and actor from scene2D. Now wants to use physics body from box2d in the game besides using actor from scene2D. But I ...
2k views

### Movement with box2d using libgdx

I am pretty new to using physics engine and would like to know what is best practice for movement of playercharacters. Currently I have a class called Hero that has a CircleShape and when the user ...
345 views

### Box2d : How to apply a force to keep swinging from left to right?

i'm losing myself in this... Situation: Working on a game in cocos2d with box2d and I have a ropejoint between one fixed body and one dynamic body. When I drop the dynamic body is swings from left ...
904 views

### Box2D: Efficient method to create b2Chainshapes for a tile-based map?

I'm working on a platforming game with tile based levels. I store the collision model for my tileset in an array. This is how the collision model for a 4x4 tilesheet would look like (I can't post ...