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

learn more… | top users | synonyms

0
votes
1answer
38 views

Libgdx using Box2d with TiledMap to create collision detection

I'm fairly new to Libgdx and have some good basic knowledge on Java. Right now I am stuck on how to add collision to my TiledMap, I am using the Mapeditor to create the tilemap. I read so many ...
1
vote
0answers
10 views

Sizing a Box2D ground object

I am developing a platformer game using SDL2 for graphics and Box2D for physics. I am currently designing my levels and would like to know if it is better to make the static part of each level (ie: ...
0
votes
0answers
12 views

LibGDX, Box2D , Destroy body into parts

I am developing a game using libGDX game engine and box2d physics engine. There are asteroids in my game, I want to destroy their bodies randomly and fill with texture. How can I do it?
0
votes
0answers
49 views

Why does physics interpolation give me periodic jumps/flickers?

I have seen this question but it didn't solve the problem. I have followed the same steps as in this article. What I notice in my Android game is that my interpolation alpha (or fraction or ...
0
votes
1answer
20 views

Box2d joints still attached after Explosion simulation

I ported simple Box2d Explosion simulation the function is called once when there is some event with the "Truck Car" the problem is that the Explosion working fine but it looks like when the explosion ...
1
vote
1answer
36 views

What are the steps for creating level in Libgdx with Box2d?

I have been trying to learn game programming for a week, although I have a good knowledge of programming. I don't understand some steps of game design. I'm recently working to clone the iSlash ...
0
votes
1answer
79 views

Good collision resolving mechanism

In my game i have plenty of objects that can collide. Literally, most of them can collide with each other.The problem I'm facing is that i can't come up with some good collision resolving way. How can ...
0
votes
1answer
41 views

Calculating density of an object

I'm using Box2D for physics in my game, and one of the things it needs to know when creating a shape for a physics body is the shape's density. I had no idea what value I should specify, so I went to ...
0
votes
1answer
43 views

How to convert pixels to meters in Box2d with Cocos2d-x 3.5?

I am using Cocos2d-x 3.5. I created a simple game with edge bodies and one circular body to test box2d. Physics wasn't working well, so i thought i should convert pixels to meters and use that meters ...
5
votes
2answers
84 views

Body lost a velocity component when hitting a wall

I am creating a Breakout game using Box2D (of LibGdx if anyone interest). Everything works well until when the ball hits the wall when moving with a very small angle. Please look at the image for ...
0
votes
1answer
39 views

box2d not centered in sprite [duplicate]

I am trying to create a bounding box for my sprite using box2d, but the box is being created at the wrong spot. I followed a tutorial on the wiki using this code BodyDef bodyDef1 = new BodyDef(); ...
1
vote
1answer
31 views

b2DistanceJoint with frequency equal to 0 vs b2WeldJoint

What is the difference of b2WeldJoint and b2DistanceJoint? They both have frequency and also when you put frequency of Distance Joint to 0 it acts like Weld Joint. It seams that you can create ...
0
votes
0answers
19 views

Setting Up the PTM_Ratio for Different Devices

I want to set the the physics for my Game and I have used Box2d for the Physics Simulation. And to do that I have set the PTM_Ratio to 32.0f.But When I run my Game on Different Android or iOS Devices ...
2
votes
1answer
52 views

In Box2D, how do I create an infinitely oscillating spring?

How do I create an ideal spring that can oscillate indefinitely using Box2D? A b2DistanceJoint works almost perfectly, but it eventually slows to a stop, even with damping set to 0. I think it is ...
1
vote
1answer
39 views

Checking if Body is surrounded by other Bodies

I'm trying to make a game like Rampart as practice. I have gotten to the point where I want to check if the castle is surrounded by walls and decide whether to fill in the area and continue the game, ...
0
votes
0answers
11 views

Box2d c++ can't see b2PolygonShape

i try to follow this tutorial and convert it to c++ http://www.emanueleferonato.com/2009/04/06/two-ways-to-make-box2d-cars/ the second part of the tutorial Now im facing very strange Behaviorno ...
1
vote
0answers
56 views

Calculate the rest length of a box2d distance joint

Given the length of a distance joint along with its frequency and the mass of the bodies involved, is it possible to determine the final rest length? I'm only interested in the vertical axis if that ...
1
vote
0answers
59 views

Using Box2D in LibGDX, is there a reason a fixture set to be a sensor would only -sometimes- detect a collision?

I am working on a 2D game in LibGDX. Currently, I am testing interactions between a player's weapon and enemies - in particular, a sword and an enemy monster. The player has a hurtbox and the sword ...
0
votes
0answers
27 views

Can't perform normal jump after applying revolute joint

I have encountered the following problem: I have two PolygonShapes which I had connected with a RevoluteJoint. The first body is called square the second is called weapon, before connecting the two ...
0
votes
1answer
90 views

My Raycast will not detect collisions in my Unity 2D project. What am I doing wrong?

I appreciate any help you can offer me. I created a script for a character controller that casts two rays below the player's gameobject. The rays extend infinitely and should collide with another ...
1
vote
0answers
78 views

LibGDX Box2D Lights - Illuminate background

I have a box2D world made of tiles. I use a custom DirectionalLight for light up the scene from above (It shines through transparent blocks [eg.: the water] more deeply). The problem is (as expected), ...
0
votes
0answers
37 views

Box2D replace Fixture not working as expected

I am using box2D to develop a simple game, and I am using the Physics body editor by Aurelien Ribon to load the fixtures into bodies. I have written the following method which should scale my ...
0
votes
0answers
32 views

Box2d :What is the best approach to build static Box2d smooth curve line [duplicate]

i want to know what is the best approach to simulate smooth curved line as static body it will be like path for car to drive . something like this : http://www.freeriderhd.com/ how does its box2d ...
0
votes
0answers
81 views

Preferred way to integrate box2d with SFML

I'm trying to integrate Box2D with sfml. My current solution is to have overloaded functions creating sfml shapes from box2d fixtureDef shapes. I store created sfml shapes under the name 'visual' in a ...
2
votes
1answer
108 views

Box2D Lights - Simulate water

I have a libGDX project, in which I have a Box2D world, which is currently filled with some boxes as a terrain. I also added a DirectionalLight to the scene for simulating the Sun. I almost have the ...
2
votes
1answer
61 views

How to restrict jumping to a single jump?

I'm making a VolleyBall game in HTML5 with PandaJs GameEngine and plugin is used physics and Box2D. The problem is that players can jump, but they can jump over the net with multiple jumps. I have ...
0
votes
1answer
49 views

Using Box2D for soccer physics

I've learned quite a bit of Box2D and I've succeeded basic stuff concluding ball physics. I want to implement 'opposing forces', as the character kicks the ball with a certain strength, with the leg ...
0
votes
1answer
427 views

Libgdx Box2D and Screen Viewport Scaling

I am currently having problems getting an easy to manage system of scaling my units for use with box2D. Normally I would create virtual units to go along with me viewport and camera but since I am ...
0
votes
0answers
22 views

How will i know if the Body is facing a the target angle [duplicate]

I want to know if the body of the car is facing the line on the picture
1
vote
3answers
72 views

How to handle transparent pixels in a spritesheet

I am trying to correctly handle transparent pixels. I have a spritesheet that gave me the following: The green body is the ground physics body and the gray body around the sprite is the sprite's ...
1
vote
1answer
108 views

Implimenting BADLAND like Body Movement in Box2d

I am trying to make a body (character in my game) move and behave in the same way as the character in the BADLAND Game with regards to rotation. The character does not have fixed rotation and behaves ...
0
votes
1answer
36 views

Box2D: Making it Determinsitic?

From articles on the web, I found that floating point math generally has accuracy of at least 6 digits. With this in mind, is it possible to make Box2D which uses floats fully deterministic through ...
0
votes
1answer
36 views

How to trim a sprite?

I have a spritesheet: var spriteSheet = new createjs.SpriteSheet({ // ... frames: { width:520, height:600, regX: 260, regY:300 } // ... }); I am computing it's physics body as follows: ...
1
vote
1answer
102 views

Dynamic body in Box2D with fixed position

I need to fix the dynamic body position so that it would not rotate and would not move even if there are other forces, collisions and so on. Let me first explain why I need this. I have a dynamic ...
0
votes
1answer
108 views

libgdx - Box2d debug draw not correct

I have a problem where the bodies in my debug draw does not draw correctly, take a look: As you can see, there is some space between the dynamic body and the ground. I have checked the contact ...
0
votes
1answer
64 views

Tiled PolygonObjects rendering wrong in libgdx

this is how I render the polygons in Tiled this is how they get rendered in libgdx. Notice the top part of the triangles is straight instead of being hollow. here is the code I use to convert the ...
0
votes
0answers
24 views

mouseWorld Coordinates Box2D

I have one simple question in Box2D: if you want to get the world coordinates of mouse, this is the function you gonna use in Java: void update(int x, int y) { if(mousejoint !=0) ...
0
votes
2answers
160 views

Libgdx box2d crashing

im making a game in libgdx which i having a bunch of circle bodies floating around in space and when the player's body crashes into another body, that body deletes and creates two smaller bodies ...
-1
votes
1answer
55 views

Relative movement in Box2D (keep object from falling off planet)

I'm creating a game with planets orbiting around a sun, like this: The brown square is the earth, rotating around its center and around the sun. The yellow square is the sun, which doesn't move. Now ...
2
votes
2answers
59 views

Pole vault with Box2D?

I would like to replicate the behavior of a flexible pole as used for pole vault. Can somebody give me some inspiration how to simulate that with Box2D? Would I cannot multiple objects with flexible ...
1
vote
1answer
56 views

Why does this impulse not affect the body?

I'm just getting started with Box2d and I'm trying to apply an impulse to a circle but nothing really happens. First I define ball: BodyDef bodyDef = new BodyDef(); bodyDef.type = ...
1
vote
0answers
57 views

Farseer: Friend/Foe Collision - cannot push foes but friends

we are using Farseer in our project and I try to find a setup to achieve the following quite complicated collision behavior: Friendly Units can push each other aside. However, the push should be a ...
1
vote
1answer
32 views

Permeable objects in Box2d

In Box2d, can I make a static object to be permeable by dynamic objects? Can I simulate something like water in a way that it lets rigid bodies to dive into it but at the same time pushes them off ...
0
votes
1answer
44 views

Set world boundaries in box2d

So far I've seen the only way to set boundaries on box2d world which is to create rectangular shapes and place them at the edges of the screen, is there any other way? Perhaps I can set boundaries ...
0
votes
1answer
50 views

Why the triangulated body in box@d as a sensor is not treated as one but separate triangle bodies?

I am making simple game - kind of race game, where you see from the "sky" your sprites with circle Box2D bodies attached and they have to move along some path/track. My idea was to detect if they will ...
2
votes
2answers
121 views

Box2D Issues determining the side of collision

I'm trying to determine which side of my object a collision is happening. In all of my searching, I have found 2 different proposed solutions, but each one has a major issue. I'm hoping that someone ...
2
votes
2answers
87 views

AndEngine rotate all connected bodies

I have created below hexagon structure in Andengine with box2D physics extension. I want to rotate whole structure with respect to center when other ball collides with the structure using physics. ...
0
votes
1answer
192 views

Move Box2D body towards mouse click

In a top down game using Box2D, I would like the player's Box2D body to rotate towards the mouse click, and then move to a point on mouse click (move, not teleport). I have worked out the rotation ...
1
vote
1answer
64 views

Rotating towards a point in Box2D

I'm using Box2d as my physics engine and I'm trying to solve what would normally be a simple problem but what has become a nightmare for me and preventing me from finishing my app. (6 months work) ...
2
votes
1answer
244 views

LibGDX camera position shifted on movement

I'm programming a game with LibGDX and Box2D and I want my camera to follow my player. But as I zoom in (because Box2Ds metric system, using camera.zoom = x) the camera is shifted when the player ...