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

learn more… | top users | synonyms

4
votes
3answers
177 views

How do I change the relative origins of a Box2D World and a TiledMap in Libgdx?

I'm playing around with Box2D and TiledMaps and I've come across this minor annoyance. As you can see, both Box2D and TiledMap render at the center of the screen. This forces me to compensate by ...
0
votes
0answers
81 views

Physics don't apply on a unique body AndEngine

I am developing a game in AndEngine. So far I managed to create everything I wanted for my sprite that was connected to a BoxBody. I was rotating it, moving it, everything was great. I wanted my ...
0
votes
1answer
36 views

Box2D `ApplyLinearImpulse` is not working whereas `SetLinearVelocity` works

I need to mimic jumping behavior for the player in my game. Player consists of two fixtures with circle and rectangle shapes. Rectangle I use to detect ground and it is a sensor. Is some point for ...
3
votes
1answer
594 views

AndEngine; Box2D - high speed body overlapping, prismatic joints

I'm trying to make good suspension for my car game, but I'm getting nervous of some problems with it. At the beginning, I've tried to make it out of one prismatic joint/revolute joint per one wheel ...
0
votes
1answer
176 views

Rotating an object about a point (2D) using box2d

i just started developing using box2d on flixel and i realise the pivot point of the rotation of an object in box2d is set to the center of an object. i had read on forums and i found out that ...
1
vote
1answer
255 views

LibGdx sprite rotation vs Box2D physics rotation problem

LibGdx sprite rotation vs Box2D physics rotation problem Tearing my hair out on this one. I am an experienced software developer, but very new to LibGdx and Box2D development. I am writing a game ...
-1
votes
0answers
26 views

box2d first step [closed]

I'm would like trying to use box2d (c++), I ever use the js version of this api. But as I try to compile the hello world code, I've got an error on world creation : "undefined reference to b2world". ...
0
votes
1answer
28 views

Box2d linear velocity unit in AndEngine

I’m using AndEngine with Box2d for a game with many moving objects. I’m developing in iOS Sprite Kit simultaneously . in iOS Sprite Kit , I use, physicsBody.velocity The physics body’s ...
0
votes
1answer
80 views

Making Player Jump

I have been editing a piece of code and I have already implemented gravity so I would like to know how i could make the player jump when the screen is touched. I would like the player bucket to jump. ...
1
vote
1answer
94 views

Change the shape of body dynamically

I have a problem where i have a ballon which i need to continuously inflate and defalte in update method, I have tried to used setScaleCenter but it is not giving desired result. Below is a code i am ...
0
votes
1answer
25 views

Ball bouncing with box2d in libgdx

I just started using Box2d and libgdx. I followed this tutorial, https://github.com/libgdx/libgdx/wiki/Box2d And a ball would bounce if I run the following code I took from the tutorial. // ...omit ...
0
votes
1answer
32 views

“Running” against a steep slope on a Box2D Platformer

Ive seen alot of pages talking about how to emulate a platformer on Box2D, specially about how people dont want to slide down a slope. Well, my problem is different and Im surprised I cant find ...
0
votes
2answers
407 views

How to get width and height from a body in box2d?

I am working on a game in Libgdx framework. I have to get width and height from a body in box2d. is their any way to get width an d height from a body in box2d??
2
votes
1answer
641 views

Libgdx import bin/xml/json from physics editor

I'm using Libgdx. I did a simple json file in Physics Body Editor and I don't have any idea how could I import it into my physic world in libgdx. Any idea will be appreciated. P.S: Sorry if there ...
0
votes
0answers
14 views

[LibGdx]Moving a fixture on a body

I'm working with Box2D and I have a basic platform and a box bounces off of it. // Static Platform bdef.position.set(160 / PPM, 120 / PPM); bdef.type = BodyType.StaticBody; Body b = ...
0
votes
1answer
43 views

Box2d pathfinding using raytracing / predicted collisions

I have a Box2d/Cocos2d iOS game with enemies that attempt to follow the player (to attack). I'm working on improving the pathfinding logic so that the enemies won't crash into objects in the world. ...
0
votes
1answer
399 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 ...
0
votes
1answer
345 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 ...
1
vote
1answer
50 views

Box2DLights - the center of sprites are always 100% unlit (black) unless Xray is on

I'm using a ConeLight at 180 degrees, with this setup: pl = new ConeLight(rayHandler, 256, new Color(0.5f, 0.5f, 0.5f, 1f), 280f, 400 - x, 300 - y, 0, 180); And the object I'm casting a shadow on ...
1
vote
1answer
104 views

Box2d - Attaching a fired arrow to a moving enemy

I am firing an arrow from the player to moving enemies. When the arrow hits the enemy, I want it to attach exactly where it hit and cause the enemy (a square) to tumble to the ground. Excluding the ...
0
votes
1answer
51 views

Set Position of multiple bodies

I have a character composed of five bodies which are tied together by a lot of joints. On of them is the overall chassis, to which all forces and impulses are applied to move the whole Character. All ...
1
vote
1answer
144 views

Dynamic Hills like Contre Jour in Cocos2d

I'm interested in maps/environments which are flexible and change at runtime, such as those in Contre Jour. I have looked for a long time to find out how to make this effect, but I couldn't find an ...
2
votes
1answer
148 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 ...
1
vote
0answers
30 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 ...
0
votes
1answer
56 views

Bodies going through the walls of a box

I have a game where the user controls a box to collect falling balls. However, very often the balls will just fall through the walls of the box and be flung away. What could be causing the balls to do ...
9
votes
3answers
4k views

Box2D Get Bounding Box of a Body

In Box2D, I was curious if it's possible to get a bounding box of a body already created in the world. So basically, the Body is created, it's interacting with the world and such. And I needed that ...
0
votes
1answer
67 views

Multiple gravity “zones” in a world

I have a world that I want to divide in two like this: ____________________ | | | | | A | | | | | ...
2
votes
1answer
266 views

How do I make my camera follow a Box2D object?

I'm implementing a camera in my game. It worked for regular objects, but I began using Box2D and obviously things changed a bit. I have a Body object that I want to draw at the center of the screen. ...
3
votes
2answers
110 views

Why are my Box2D wheels slipping on ground?

I have a car, set up in Box2D as a rectangle connected with two wheels using WheelJoints: The wheels are defined as follows: FixtureDef wheelFixtureDef = new FixtureDef(); ...
0
votes
1answer
36 views

Get position of Fixtures

I'm constructing a Body (a box2d body using AndEngine) using multiple Fixtures and later I need to get the world position of these Fixtures. Currently I am trying something like this; // ...
1
vote
1answer
86 views

LibGDX Box2DLights shadow offset problem on bodies

Hello I just started to use LibGDX, and it's awesome. I looked at the Box2DLights library, and started to learn how the lighting work here. I got something up: As you can see, it works, but the ...
1
vote
1answer
36 views

Love2D Box2D RevoluteJoint and Anchors

and apologies in advance for this fairly random question. I'm using Love2D 0.9.1 and Box2D to create two bodies joined by a revolute joint. A simplified representation of the two bodies is a Sphere ...
1
vote
1answer
24 views

In JBox2D, where is the correct place to interact with Body objects? step() method?

QUESTION: In an application, where is the appropriate place to put the code to interact with the Body objects? By 'interact' I mean Get position Determine actions Apply impulse Would it be ...
-1
votes
1answer
49 views

What's the difference between Box2D and tweening?

It seems like Box2D can be used to move sprites across the screen, so how does this differ from tweening? Is it that Box2D is for physical collision detections and tweening is just animations?
1
vote
1answer
4k views

LibGDX Box2D Body and Sprite AND DebugRenderer out of sync

I am having a couple issues with Box2D bodies. I have a GameObject holding a Sprite and Body. I use a ShapeRenderer to draw an outline of the Body's and Sprite's bounding boxes. I also added a ...
6
votes
1answer
124 views

How can I predict player-to-projectile collisions in Box2D?

I'm making a real time shooting game with Box2D as the physics engine. The gameplay is mostly about trajectory, like Angry Birds. I want to make a slow motion effect and move camera to the player when ...
0
votes
0answers
27 views

Box2D collision damage calculation from postSolve or not?

I'm using postSolve to get impulse then calculate damage base on that impulse. But there's some issue: Stability The damage isn't stable. When the same ball is hitting with same speed, the damage ...
3
votes
0answers
90 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 ...
4
votes
1answer
843 views

Problem Implementing Texture on Libgdx Mesh of Randomized Terrain

I'm having problems understanding how to apply a texture to a non-rectangular object. The following code creates textures such as this: from the debug renderer I think I've got the physical shape ...
2
votes
2answers
46 views

How can I add an impulse to specific rigid bodies at rest?

Scenario Rocks falling down a rocky slope, with a flat surface at the bottom. When they land on the surface, the rocks move slightly before coming to a rest. GLESDebugDraw shows the bright orange ...
1
vote
1answer
76 views

Libgdx Box2d createfixture crashes vm intermittently

I have a hard to debug problem. I have a Box2D game which creates a wheeled vehicle. I want the vehicle body to reflect when it goes from moving left to moving right. to do this i set a flag in a ...
0
votes
0answers
45 views

sprite reset method not working in update thread(andengine)

I have sprite array with length of 8 and I am trying to reset sprites position in scene's update thread but it doesn't work. However I tried to reset sprites in sprites modifier listner which works. I ...
4
votes
1answer
695 views

How would I make an air hockey AI?

I am making an air hockey game for Android using AndEngine and its Box2D extension. How would I make an AI for an air hockey game? For it to work the AI would not only need to move its paddle side ...
0
votes
0answers
11 views

Complex Body with multiple BodyDefs

My complex body is made up of several parts some of which are static and some are dynamic and have specific positions relative to each other. Because the static/dynamic property and position goes in ...
3
votes
1answer
120 views

determine collision angle on a rotating body

update: new diagram and updated description I have a contact listener set up to try and determine the side that a collision happened at relative to the a bodies rotation. One way to solve this is ...
0
votes
3answers
200 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 = ...
1
vote
0answers
36 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 ...
0
votes
1answer
30 views

Inertia in flight simulation using box2d

I'm trying to simulate flight using box2d and libgdx. The main problem I am currently experiencing is with inertia: since there is no air, the plane looks like it were drifting. I wasn't able how to ...
1
vote
1answer
118 views

How to optimize a box2d simulation in action game?

I'm working on an action game and i use box2d for physics. The game use a tiled map. I have different types of body: Static ones used for tiles Dynamic ones for player and enemies Actually i ...
1
vote
0answers
48 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 ...