Questions tagged [box2d]

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

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

Web site | FAQ | Manual

It has been ported to various other platforms and engines:

Many of the ports have no manual, but most closely follow the original one.

812 questions
7
votes
2 answers

How to create an extensible rope in Box2D?

Let's say I'm trying to create a ninja lowering himself down a rope, or pulling himself back up, all whilst he might be swinging from side to side or hit by objects. Basically like http://ninja.frozenfractal.com/ but with Box2D instead of hacky…
Thomas
  • 578
  • 4
  • 13
4
votes
1 answer

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 dies. How can I detect when the player box is…
Distraction
  • 143
  • 2
4
votes
2 answers

Can i add friction in air?

I have issue regarding speed in air. When i jump and move simultaneously that time speed of player increase.For jump i am using impuls and for movement i am using force.I want to slow speed when player is in air. Thanks in advance Following is my…
Diken
  • 85
  • 1
  • 4
4
votes
2 answers

Box2D Raycast - Getting position / angle of edge hit

I'm casting a ray in Box2D using b2World.rayCast how can I get the normal of the wall which was hit? Or better yet - the line start and end points? The information returned is: Fixture (fixture hit, and parent body) Point ( Location of hit ) Normal…
onedayitwillmake
  • 1,203
  • 1
  • 11
  • 22
4
votes
4 answers

Fix joint length in Box2D?

I'm having some difficulties with Box2D DistanceJoints, I'm trying to create a rope using DistanceJoints connecting some bodies together but the length of joints between bodies change due to weight of bodies, is there any way to prevent joint…
Ali1S232
  • 8,687
  • 2
  • 40
  • 59
4
votes
1 answer

Box2d: Is there a way to have collisions but ignore the accompanying forces?

To begin, I know that you can use filtering or isSensor to remove physical collisions. However, I would like to retain the ability to, say for example, stop when trying to move past another player. Essentially, I don't want one player to be able to…
jpanda109
  • 71
  • 5
3
votes
2 answers

Spawning bullets on command in Box2D

I'm making a simple bullet hell game but I can't figure out how to get my character to shoot. Lets say I have bulletBody and shipBody, how would I continually spawn bulletBodies using the shipBody coordinates. I've tried a function that uses an…
3
votes
1 answer

Where would I update a graphical representation of a b2Body in Box2D's solver?

Hey i'm trying to make a class called BodyRep Which is supposed to use SFML too sync a graphical representation and Box2D Bodies orientation/location. To do this i plan to ovveride some Box2D function so that it does it's original steps, plus one…
Griffin
  • 630
  • 1
  • 12
  • 26
3
votes
1 answer

Object in Box2d doesn't sit perfectly on top of other object

I have a rectangle in my player class with the following properties b2BodyDef player; player.type = b2_dynamicBody; player.position.Set(x + width, 10.17f - (y + height)); m_PhysicsBody = level->GetPhysicsWorld().CreateBody(&player); b2PolygonShape…
Sean Carey
  • 694
  • 6
  • 14
3
votes
1 answer

JBox2D becomes very slow on mobile phones after 80-90 dynamic and static bodies

I have a simple game with 20-30 physics bodies (static, and dynamic) If I add some additional Dynamic bodies and joints (over 80-90 item), then JBox2D will become very laggy, and a little slow. Am I doing something wrong, or is this the limit of…
lacas
  • 346
  • 3
  • 14
3
votes
1 answer

Get Vertices of a Shape/Body in Box2D

Is there a way to do it? I can get only polygon_shape's vertices, but i want circle, box, etc too. How to do it?
lacas
  • 346
  • 3
  • 14
2
votes
0 answers

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 makes the formula simpler. E.g. Imagine the simple…
2
votes
1 answer

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 in all that works very fine, except one thing: I…
philipp
  • 389
  • 1
  • 15
2
votes
1 answer

Is it bad practice to set the velocity of an object every loop?

Say I have a simple game with a gameLoop function that gets called every 50 milliseconds or something similar, and I have a box2d object. Is it bad practice/too CPU intensive to use SetLinearVelocity on the object every time the gameLoop is called?
starscape
  • 416
  • 3
  • 9
2
votes
1 answer

Best way to allow a user to Control Body in Box2D

I am working on a simple game and I am deciding how I should let users interact with the world. I really have 2 options, 1.) When the user moves an object I apply a force to the body 2.) With each move iteration I "move" the body by setting…
Jackie
  • 455
  • 1
  • 7
  • 16
1
2 3