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

2
votes
2answers
61 views

Jump-through & drop-down platform

I'm creating platforms in my game where the player can: 1) Jump through them from the bottom and land on top of them 2) While on top of them, drop down through them I've been able to get #2 working ...
1
vote
1answer
25 views

How to distinguish between full/partially intersecting Collider2D?

I'm using Unity 5 to make 2D game. I have a screen (gray), arena (green) and player-controlled object (yellow) that can be moved across the screen with mouse before placement: There is no ...
1
vote
3answers
97 views

Limit access to socket end point

I'm developing a multiplayer canvas game based on socket.io and box2d physics engine. Is there a way to limit connections to my socket endpoint and only allow connections from a specific domain? ...
1
vote
0answers
30 views

Different Box2D bodies act differently and unexpectedly with same mass

I have a box2d body which is simply a rectangle (the spaceship). This ship flies around, affected by the gravity of planets (static circle bodies) just fine. I have tried changing the ship fixture ...
1
vote
1answer
31 views

Joint based destructible physics (like Armadillo Run)

I've implemented a destructible terrain system like Worms before (where weapons create holes in the terrain), but for the game I'm designing I want something more like Armadillo Run: https://www....
1
vote
0answers
7 views

Game freezing when i create a body Box2D Libgdx

I'm implementing a Worms game using libGDX and Box2D and I'm having a problem I didn't have until recently. When a player shoots, it creates a bullet body and applies a force to it. I have a step ...
1
vote
0answers
107 views

How to correctly implement 'layered lighting' with Box2D-Lights

How does one only allow Box2D-Lights to affect one and only one OrthographicCamera. After researching, I found the following answer. This answer goes into detail about how to prevent one camera from ...
0
votes
2answers
159 views

2D Platformer: add ability to jump on top of other character

I want to add ability to jump onto a head of other character/player, but still be able to go through them horizontally. There is one useful tutorial about one-way platforms, but that approach doesn't ...
0
votes
0answers
23 views

libgdx box2d move object in bezier curv

I'm making a game and i need to move my game object in a bezier curv path i succeeded in doing it: //create Bezir curv .... path.valueAt(outMove, val); path.derivativeAt(...
0
votes
0answers
8 views

LibGDX Box2D Body shape transformation

In the following method my player Body is created: public static Body createPlayer (World world) { BodyDef bodyDef = new BodyDef(); bodyDef.type = BodyDef.BodyType.DynamicBody; ...
0
votes
0answers
38 views

Decrease force in a zero gravity world

I have a world with zero gravity. On a mouse pressed I apply a force so things drive away from the mouse. The problem is now that they keep on flying. How can i make them stop? box2d.world....
0
votes
1answer
60 views

How to apply Buoyant force to a Box2d body?

I have been following a formula to calculate the buoyant force needed to apply to a dynamic body to be able to simulate water. Fb = ρgV Fb - is the buoyant force ρ - density of the liquid g - ...
0
votes
0answers
42 views

LibGDX works well on android 4 and very bad on android 5 and 6

I have a problem with my game. The game is made with libgdx, scene2d and box2d and it uses an AssetManager. I tested this app on all my devices and here it is the results: Galaxy S3, android 4 (...
1
vote
2answers
54 views

LibGDX game crash without errors (maybe AssetManager)

i have a problem with my game. It's a endless run shooter/platform made with LibGDX (Scene2d and box2D). I do tests with LG G2, LG G3, Galaxy s4, desktop and android emulator and i have no one ...
0
votes
0answers
33 views

Box2D + SDL - Weird body positions

I'm having a problem where either my sprite, or my body position is off. Here's a picture so you can see exactly what's going on : (The box has stopped on the picture, probably because it's colliding ...
0
votes
2answers
45 views

How to create a linear plateform between two points?

I have a set of 2D coordinates. Their positions are regular on the X axis, but unpredictable on the Y axis: I would like to create slim platform between each point in order tu use it as ground for ...
0
votes
0answers
151 views

Box2dMapObjectParser isometric map - bodies have wrong position and size

I'm using Box2dMapObjectParser to load Tiled objects layer onto my IsometricTiledMapRenderer'ed TiledMap. It works OK with a UnitScale of 1 but the position is wrong and some shapes have weird ...
0
votes
1answer
78 views

How to split a screen in half using LibGDX without scaling?

I am currently working on a racing game with libGDX and I need to split the screen in half for a two-players mode. (Player 1 in first half and Player 2 in second half). I already have Camera1 that ...
1
vote
0answers
37 views

Best way to create defence(withdraw) algorthim libgdx?

I have created user body and enemy body. Enemy body uses the steering behavior created by gdx AI. User body have it own control inputprocessor. World doesnt have gravity. Enemy body arrives the user ...
0
votes
1answer
46 views

Libgdx Sprite rotation around specific point

I made complex dynamic body that rotates around other body that is static. It works perfectly, however I got messed up with sprite position on that body. Here's what I have now and here's what I ...
0
votes
0answers
52 views

Why is my tiled map moving when I move the camera in libGDX?

I use LibGDX. I have created a map with Tiled Map Editor and loaded it to the game. Everything else is working well, but when I move the camera, the map moves: it jumps or floats. My code: public ...
0
votes
1answer
16 views

Box2dWeb: rotating object about a point

I am having problem rotating box2d object back and forth around a point. To better understand my problem i have prepared an example clicking on key rotate the paddle when u click again the paddle ...
1
vote
0answers
76 views

Java Libgdx Attaching Sprite to Box2D Body

So I am working on programming a java 2D platformer for fun on the side and I have a rendered TMX level and a box2d body (just a circle shape) that I am currently using as my player. All the controls ...
0
votes
0answers
39 views

How can I simulate a basketball throw in LibGdx box2d?

So I want to simulate a similar throw like in the game Bouncy Basketball. Do i need to create a body and attach another body on it that would be the arm and then how would I apply force/impulse to the ...
0
votes
0answers
23 views

Box2d capsule stumbles on ground

I am working on a game with box2d and sdl. I Created a character and some boxes as ground, but faced the problem where the character would run a few meters, and stumble on one of the boxes' edge. I ...
0
votes
0answers
49 views

Box2D Physics Crazy

I have a simple Box2D Game with a dynamic player, a static floor, and a matrix of gems. The problem is that the physics engine goes crazy. You can see in this video: https://youtu.be/iaH_ex8eVVk ...
0
votes
2answers
65 views

Sprite not drawn on the same position as its Body LibGDX after implementing Pixels Per Meter Division on Box2D

I had a problem where the sprite was not positioned on Body correctly which I solved and you can see it here: Box2D is not positioned on the sprite correctly LibGDX After I solved that, I needed to ...
1
vote
1answer
87 views

How to handle two players playing on one keyboard with Box2D (LibGDX)?

I'm making a racing game with LibGDX and Box2D. I've been using this tutorial to implement the basic physics, and it works properly. My main problem is to implement two different sets of keys (UP-...
0
votes
2answers
62 views

Box2D is not positioned on the sprite correctly LibGDX

I have a strange issue where my Box2D is not being positioned on the player correctly. Down is the picture: What I find more strange is that the Box2D is positioned correctly on the cloud that is ...
0
votes
2answers
95 views

Why is my character passing through in Box2D?

I have a collision problem in Box2D. I am trying to do a simple platform game with Libgdx, Box2D and TiledMap. I have a map made with TiledMap: I load the map in my Android game. I read all the "...
0
votes
1answer
65 views

LibGDX--constant high score in top corner

I'm currently programming a game using LibGDX and box2D. I have a sprite (player) that moves up the screen, kind of like doodle jump. I'd like to have my camera to be centered around the player at ...
2
votes
1answer
76 views

Box2D fixed timestep updating is twitchy on constant FPS

I'm messing around with libgdx and box2d and I'm trying to implement sidescroller movement with fixed timestep logic according to the famous Fix Your Timestep! tutorial/guide. However, logic updating ...
2
votes
2answers
137 views

Box2DLights in libGDX - Bad quality of the light gradient on Android

I am facing a problem while porting one of my libGDX project from desktop to Android : My game uses Box2DLights. While the light effect look very fancy on the desktop version of the game, it looks ...
0
votes
0answers
40 views

How to Implement a 2d camera object for a side scroller game

Ok so Heres the problem. I'm Using c++ with sfml for graphics and box2d for physics. I've tried an ultra simple cam movement in the past where i lock the player to the center of the screen and offset ...
0
votes
1answer
38 views

Libgdx + Box2d working with 2 cameras

Recently I have read that you can work with 2 cameras whenever you involve Box2d, which only works in meters. In my Renderer class, I receive all the entities in the game and then draw them. I work ...
0
votes
0answers
39 views

Box2D top down car weird spasm

im currently programming a 2d top down racing game with box2d and libgdx. i have a car body to which there are 4 wheels attached. these 4 wheels are attached with RevoluteJoints ( for the front ...
3
votes
1answer
65 views

Problem merging vertices of two polygonial bodies

SUMMARY I need help to create a weld joint that fixes the two bodies together in a way as illustrated in the first image. ISSUE I am having an issue where I cannot find out how to weld vertices of ...
1
vote
3answers
228 views

Box2d set sprite to body that rotates around specific point

I want to rotate kinematic body around a specific point (I already done this part using shape.setAsBox(1.8f / PPM, 0.2f / PPM, new Vector2(5.2f, 0), 0); What I try is this: PolygonShape shape ...
0
votes
0answers
119 views

Box2d - Texture lagging and flickering

I'm having issues with texture rendering in my game. I've done a lot of research and repeated the same steps of tutorials over the internet to render and update Sprite positions properly. Somehow, ...
0
votes
0answers
71 views

Libgdx and Box2D TiledMap render is not smooth

I'm building simple side scroller game. My player (square) move fast and it interacts with other world objects. Problem is when my player is moving it seems that all world is rendering somehow strange ...
0
votes
2answers
48 views

Libgdx box2d bodies go through other bodies

I'm developing a game using libGDX and box2d. I am facing a problem that bodies go through each other... I'm moving the body using a TouchPad by setTransform. I think the problem is that I use ...
0
votes
0answers
20 views

LibGDX: Is there any way to check if space between 2 bodies is free?

I know how to calculate the distance between 2 bodies in my game using Math.hypot(x,y); but I need to know if between those bodies the space is free, I mean, without any body.
0
votes
0answers
36 views

LibGDX & Box2D Actor Collision

I'm working on a LibGDX project, and I was wondering about the best way to define actors in a collision. I know this is probably a common question, but specifically I'm interested in beefing up one ...
0
votes
0answers
31 views

ChainShape in Box2D

I recently began to learn libgdx and I am stuck at a problem with the CainShape of Box2D. My first goal is to simply create a box with a ChainShape. In order to achieve that, I added four Vector2 to ...
0
votes
0answers
26 views

Libgdx moving a body sequence

How can I move a body (box2d) to different points in an order. Like first it moves to 100,200 then to 200, 450 and so on? I've tried actions(and actor) but I can't get the point where the body is ...
1
vote
1answer
109 views

LibGDX Box2D texture on dynamic generated body

I'm creating a game that is similar to hill climb racing. I've generated the ground and now I want to add texture to the ground. Here is a screenshot of a game Here is my code (I create ground using ...
0
votes
0answers
41 views

libgdx box2d car wheel circle collision with ground

I'm creating game similar to hill climb racing. I have created car (which is basically polygon with two circles) and ground generated by sinus. Now here is the problem: when my car try to climb in ...
1
vote
1answer
46 views

Libgdx Box2D random positions and intervals falling bodies

I need to make that objects fall from the top of the screen random intervals and positions. Here's my code where I create lot of objects and add them to ArrayList private void createBalls() { ...
1
vote
1answer
59 views

Problems managing collision filtering

I have my character fixture and body(is a tank), so when I press the screen it throws a rocket(which also has a body and a fixture) that the player can controlll touching the screen. My game also has ...
0
votes
1answer
61 views

How to make a ball hit many tiled circular objects in LibGDX

Hey guys I've been learning to make games with LibGDX. I did a tiled map in Tiled and the rest of code in java using Android Studio. I could make a ball bounce on the flour using Box2D, but I can't ...