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

learn more… | top users | synonyms

1
vote
0answers
8 views

Box2D body rotation with setTransform

I' having a problem rotating a body with setTransform(), The body has multiple sensors that should rotate with the player. The rotation works but it rotates around the bodys local 0,0 position instead ...
-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
81 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. ...
0
votes
1answer
26 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
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 = ...
1
vote
1answer
51 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 ...
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 ...
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 ...
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 | | | | | ...
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. ...
3
votes
2answers
111 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
88 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
37 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?
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 ...
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 ...
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
105 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
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 ...
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 ...
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
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 ...
0
votes
1answer
66 views

How to make player rotate towards mouse [duplicate]

I'm making a top down shooter with Three.js and Box2d. I'm displaying all of the graphics in 3d, but all of the physics are done in 2d, so it's sort of like super smash bros in a way. Anyway, how can ...
1
vote
1answer
119 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 ...
0
votes
0answers
50 views

box2dlights conelight rotation is off

I'm using libgdx/box2dlights for my game~ I have a conelight set up as such: ConeLight cl = new ConeLight(rh, 32, new Color(0f, 0.0f, 0.0f, 1.0f), 3, 0, 0, 0, 1); where "rh" is a RayHandler set to ...
-1
votes
1answer
67 views

simple collision detection with box2dweb

im beginner in box2dweb that version of box2d for javascript i wrote simple gravity system and i want to detect the collision between the box and the ground , when the falling box hit the ground ...
0
votes
1answer
30 views

revolutejoint doesn't seem to rotate

I have a revolute joint set up as such in libgdx + box2d: RevoluteJointDef rjd = new RevoluteJointDef(); rjd.initialize(body1, body2, arm.getWorldCenter()); rjd.motorSpeed ...
0
votes
0answers
46 views

Box2D and randomly generated tilemaps

I am making a 2D Terraria-style sidescrolling game. I want to use box2d for the physics. However, I am using tilemaps for the maps, and I do not know of a processor-efficient way to use Box2D bodies ...
2
votes
2answers
128 views

how do I create a moving type of block like in Mario[box2d]

I want to create a block which only moves up and only when hit from below. I am trying out a distance joint and I read it can be used as a spring, is this the correct solution? the way I have tried ...
0
votes
0answers
34 views

Box2d not showing consistent behaviour with sprites

Box2D newbb here. My question is in regards to this create js project:http://mboyeman.com/dashingdog/ (runs best in IE...:3) I wrote a function(assignBlockBodies) to give 2D Edges to sprites based on ...
1
vote
1answer
260 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 ...
0
votes
1answer
40 views

How to set LinearVelocity exactly in onSceneTouchEvent?

I'm beginner in Android programming. And i use AndEngine GLS2 with Body and AnimatedSprite. I have a object ball and i want to move it to follow my hand. This is description for my idea: And my ...
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 ...
1
vote
1answer
95 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 ...
2
votes
1answer
91 views

Using Box2d to model rotating turret

I would like to model a rotating "turret" on top of a tank-like object in 2D from the side view like pictured here: Notice the faint outline of a gun protruding to the upper left courtesy of ...
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 ...
1
vote
1answer
138 views

How to rotate an image around its own center in AndEngine?

I'm beginner in Android programming with Andengine framework. And my question: How to rotate an image around its own center in AndEngine? I use Body and AnimatedSprite. Update This is my code: ...
0
votes
0answers
126 views

Shifting the camera and setting a new scene when using Box2D

My jsFiddle: // START -- MOVE CAMERA var p = new b2Vec2(); p = (ball.body.GetWorldCenter().x) * physics.scale; pos.push(p); var length = pos.length; var s = (pos[length - 1] - pos[length - 2]); //in ...
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 ...
0
votes
0answers
43 views

2D Range Searching

I have a 2D jump'n'run browser game based on SVG, whereby the entire game-world is included in one huge svg (28px * 16000px, ~3.5MB). Unfortunately is rendering kind of too complex and the browsers ...
1
vote
1answer
73 views

Preventing rapid inversions of boolean on Collision detection

I know this is both a strange question and a stupid question. But this is an issue I have dealt with in every single game I've made, and I have yet but to find a solution. I can't be the only one ...
0
votes
0answers
42 views

setChaseEntity freezes or jitters the AnimatedSprite

I'm trying to implement setChaseEntity method in a physics based app. I wrote the below code which has an animated sprite ans as the player. The player is movable and it can jump. When i try to focus ...
0
votes
1answer
83 views

Player doesn't jumps in Box2D implementation [closed]

Well, i'm trying to learn andEngine. I was able to successfully implement the move functionality for the player. Now, i'm trying to make the player jump using Box2D. I referred few online tutorials to ...
0
votes
1answer
63 views

Is there any reasons to make sprites and bodies line up?

So in LibGDX the Sprite objects position is where it's 0,0 mark is in the word. In Box2D a a bodies position is in it's center. So to line these up when you update the sprites position with the ...