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

4
votes
0answers
164 views

Ledge climb animation and movement (2d platformer)

Struggling to make a decision on the implementation of a ledge climb mechanic for a physics driven 2d platformer. What is the best way to go about this without it getting overly complex? So far I ...
2
votes
0answers
60 views

Get a body from TiledMap via MapBodyBuilder and draw a sprite on it in LibGDX?

I use a various of MapBodyBuilder in my Libgdx project. I created a body from map.tmx via my MapBodyBuilder and in my SpriteBuilder buildSprite method i created its sprite: sprite = new ...
2
votes
0answers
66 views

Rotating kinematic object around a moving point Box2D

I'm new at Box2D and I am making a simple game where you control the rotation of the maze and the gravity leads the ball to the exit. The game looks like: The problem: I want to rotate the maze, ...
2
votes
0answers
49 views

balloon ligher than air with libgdx, impementation of FixtureDef.density, gravityScale, linearDamping?

I use libGdx/box2d's physic. My intention is to create a balloon filled with helium (a body, what hovers above a surface, if we apply a little force to it - it moves fast but not far, if we push ...
2
votes
0answers
182 views

generate box2d bodies from isometric tiled map

I followed the tutorial here to generate box2d bodies from a tiled map and that worked fine.... for orthogonal tiled maps. Unfortunately isometric maps use their own coordinate system where (0, 0) is ...
2
votes
0answers
318 views

beginContact triggered more than once on some objects

Short version: It looks like beginContact is detecting continuous collisions. I'd like to avoid that. Long version : I use Box2Dweb to write a 2D platformer. It's my first game using this lib, and, ...
2
votes
0answers
823 views

changing body type without change of center of mass

I have an box2d project with some bodies in it, which move around without any user interaction. But if the user selects one of the bodies, he should be able to move it around just like he wants to. ...
1
vote
0answers
33 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 ...
1
vote
0answers
30 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 ...
1
vote
0answers
24 views

Movement for Box2D Bodies

I'm having trouble wrapping my head around something that should be relatively simple. I'm making a breakout clone using LibGDX and Box2D. I'm also using the Ashley ECS. For movement with bodies, I ...
1
vote
0answers
59 views

Moving box2D body with texture?

I was following the solution from this http://stackoverflow.com/questions/20180063/box2d-body-with-texture. I ended up getting this working for static bodies. But when trying to get the PolygonSprite ...
1
vote
0answers
79 views

Should I compute impact damage with energy or momentum?

My game uses physics (Box2D in particular). Just about every object in the game can be destroyed, and the primary method of combat is by slamming objects into one another at high speed. It makes ...
1
vote
0answers
36 views

Multiple bodies or multiple fixtures for a wall in Box2D?

I am making a game with a sort of "playfield" where the game takes place, acting as boundaries on a top-down shooter. I am using Box2D for physics, and I am questioning which of the following would be ...
1
vote
0answers
21 views

LibGDX: Box2d hovering, rotating body

Hello I am working on a hovering triangle (equilateral triangle). The triangle should allways rotate at a constant speed and hover over the ground. The problem is if I setAngularVelocity it does rise ...
1
vote
0answers
61 views

How to disable static friction in Box2D?

I'm making a 2D platformer. One of the issues is that when the character hits the ground, there's an initial pause and then the character finally slows down to a halt. I believe the initial pause is ...
1
vote
0answers
50 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: ...
1
vote
0answers
60 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
265 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 ...
1
vote
0answers
90 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
0answers
94 views

Mouse click coordinates not mapping to Box2d world

I'm using Box2d in Java with OpenGL, trying to detect if a mouse has clicked on a Body. But having trouble mapping mouse coordinates to Box2d world. I have a Body positioned at 20.0f, 30.0f in the ...
1
vote
0answers
370 views

Libgdx/Box2D PolygonShape has no position… well, what now?

As my prototype works perfectly fine I want to advance to more fun areas of the project and add a more complex player-character body. So for Box2D I figured I'd need multiple fixtures, like one for ...
1
vote
0answers
75 views

How to tell if a fixture is being squeezed by two other fixtures in Box2D?

Let's say I had a ground fixture, a player box, and a kinematic block moving up and down. If the player stands under the block, weird things happen. I want to simply play an event where the player ...
1
vote
0answers
119 views

Box2D random crash when adding joints

I'm currently working on a project which uses Box2D, when the player uses a certain key it should anchor to the ground. For that I use a weld joint, but when I add the joint the game will sometimes ...
1
vote
0answers
108 views

unity4.3 rigidbody2d unexpected force behaviour

So guys ive edited the question and here is what my problem is i have a player which has a rigidbody2d attached to it.my player is able to doublejump in the air nicely and stick to walls when ...
1
vote
0answers
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 ...
1
vote
0answers
220 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 ...
1
vote
0answers
365 views

Image Texture Tracing Algorithm - Cocos2D Box2D

Context: I am working on a 2D Destructible Terrain engine for Cocos2D with Box2D. All images, when a level loads, have their border's traced and cached for the purposes of forming Box2D b2EdgeShape ...
1
vote
0answers
1k views

Why do restitution values less than one still cause infinite bouncing in Box2D?

I'm currently trying to implement basketball bouncing into my game using Box2d (jBox2d technically), but I'm a bit confused about restitution. While trying to create the ball in the testbed first, ...
1
vote
0answers
967 views

How to properly add texture to multi-fixture/shape b2Body

Hello to everyone this is my first poste here I hope that will be not fail start. At start I must say I make part 1 in Ray's Tutorial "How To Make A Game Like Fruit Ninja With Box2D and Cocos2D". But ...
0
votes
0answers
117 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
0answers
46 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
0answers
27 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
16 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
48 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
0answers
36 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
0answers
37 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 ...
0
votes
0answers
68 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
56 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
0answers
19 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
34 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 ...
0
votes
0answers
23 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 ...
0
votes
0answers
36 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 ...
0
votes
0answers
69 views

How to dynamically draw a filled polygon with a given array of vertices?

Say I have a simple array of vertices (or floats with every odd index being the X of a vertex and every even being the Y), how could I paint all the area between the vertices? As in, I have maybe ...
0
votes
0answers
31 views

Get entity at supplied world position LIBGDX

So I'm making a simple 2D rpg. What I need is to be able to interact with the entity that the player is looking at. I need to be able to look at E.g another player in the world and press 'E' and have ...
0
votes
0answers
71 views

LibGDX Box2DLights - Global Illumination

I'm using LibGDX + Box2D to create dynamic lights in my game, but I'm currently stuck. I'm trying to light up every game object in the game with its own shadow, kinda like global illumination. Do you ...
0
votes
0answers
27 views

Libgdx Box2D - Object not showing up

I am trying to put a sprite into my b2d-world. But for some reason, it is not showing up. I've already checked the camera settings, they are defenetly correct. Then I came to the point to check the ...
0
votes
0answers
52 views

Rendering BOX2D shapes with LIBGDX

I have been creating a game on my own and I need a little help to begin with graphics. I haven' t found much in the internet about this topic, so I came here. Right now I've got a chainshape that i'm ...
0
votes
0answers
30 views

Touch and Collisions not working together in AndEngine when i set a custom Physics Handler

I have a set of custom sprites which implement a custom physics handler. The aim is to allow the user to move them by touch, then upon release they should act like a spring is connecting them to the ...
0
votes
0answers
19 views

Box2D revolute joint positioning

I'm trying to auto test some basic assumptions about how bodies tied together with a revolute joint should be positioned: void tst_GameController::physicsJointInitialPosition() { ...