Questions tagged [box2d]

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

Filter by
Sorted by
Tagged with
0 votes
0 answers
20 views

Box2D issue with setLimits on a RevoluteJoint

I have a top down 2d view, a revolute join and a "wheel" attached to the joint. I'm setting the limits of the joint to follow the angle direction of the mouse gradually. I'm also trying to ...
2 votes
0 answers
28 views

How to connect particles to rigid bodies in LiquidFun?

In vanilla Box2D various types of Joints can be used to connect two rigid bodies together. The LiquidFun extension brings the Particle Module, but I was unable to find a way to connect a particle/...
0 votes
0 answers
31 views

Box2D simulation super slow during vsync

I've been developing my own game engine for the past few days and it's time to add physics. But before adding it in the editor itself, I opened a separate project and tried box2D with SDL2. I always ...
  • 31
0 votes
0 answers
26 views

Box2D Lite demo by Erin Catto : How Baumgarte stablisation works with Arbiter and what "Allow Slope" means?

Hello Game physics developers, Hope you are having a good time. I am trying to write basic 3D box-box rigid body collison resolution. I was able to copy paste BIG BEEP formula to generate two impulse ...
1 vote
1 answer
44 views

Box2D not updating b2Body* positions

For context, this is inside my custom 2D game engine. Inside the editor code, when the 'play scene' button is clicked, the scene creates it's b2World and then ...
  • 27
0 votes
0 answers
25 views

Dynamic bodies falling onto static body tunnel through each other or fail to bounce

I have a problem with Box2D when 2 dynamic bodies fall onto a static body located below when their restitution is non-zero. They tunnel through each other instead of a rigid elastic bounce. If I treat ...
0 votes
0 answers
29 views

How to update the version of Box2D used in AndEngine?

I need help to use an updated Box2D library where the current version is > 2.3.0. I am unable to find a compatible library and do not know how to compile one for use with the Java Native Interface (...
0 votes
0 answers
44 views

How do I implement rigid body collision response out of particle simulation with extended position based physics

could you please take a look at this simulation and tell me how can I fix it, it works best on mobile: https://eguneys.github.io/ode-solver/ I want rectangles to be draggable also respecting collision ...
  • 237
0 votes
0 answers
55 views

The player gravity decreases when I add linear damping

Recently I added p_pBody.body->SetLinearDamping(8.0f); code to my player's instantiate code to prevent my player from sliding after I move right or left. Now the ...
  • 1
0 votes
1 answer
31 views

Change screen size in PyBox2D

I would like to use pybox2d's Framework class to visualize the simulation. However, the default screen / windows size is 640 x ...
  • 111
0 votes
1 answer
36 views

Perpendicular inelastic joint of two bodies in PyBox2d

I would like to create two objects of different density and (inelastically) weld them perpendicular together, so that the final object forms an L. Afterwards, I want to be able to assign a position ...
  • 111
0 votes
1 answer
45 views

Box2D bodies order inside the world

I'm working on a small platform game using box2d. When I create the game's objects I store them inside a vector. One for dynamic bodies and one for static bodies. ...
0 votes
1 answer
59 views

Sometimes player moves too much

I'm working on a simple platform game. I have the player - a dynamic body, which moves by ApplyLinearImpulse. Generally it works very well, but sometimes the player ...
0 votes
1 answer
95 views

Box2D make dynamic body fixed on the y axes

I working on a game project using C++ with SMFL and Box2d. I'm basically recreating the game "Jump and Hover", a simple platform game. In the game ther is an platform thats "hovering&...
0 votes
1 answer
186 views

"Fix Your Time Step" Variable or Fixed Physics "timeStep" parameter for Step in Box2D?

I have seen multiple contradictory articles on this topic. Have been trying to implement the Should the function call ...
0 votes
0 answers
72 views

Box2D Body cannot be serialized. How to ignore or serialize it successfully?

In my game, which implements the network functionality with Kryonet, I would like to send a class ("MyBox2DComponent") over the network which e.g. contains a field of type Body (Box2D). Of ...
0 votes
1 answer
29 views

Box2D & Processing - Collision location randomly assigned to center point

I am working on a particle simulation using Box2D with Processing. The setup: I generate 4 kinds of particles that exist in equal amounts (for instance 200 in total, 50 each). They are (for now) ...
  • 11
0 votes
0 answers
160 views

character movment and physics on 2d game

I'm developing a client/server multiplayer game. in server side i need prevent players cross map objects like walls also i need prevent player go inside each others, instead want to slide them along ...
  • 113
2 votes
0 answers
73 views

Implementing a custom joint in Box2D

I would like to implement a "rail joint" in Box2D: a joint which lets a body move only along a given curve. I couldn't find anything about defining custom joints. Is it possible at all ...
0 votes
0 answers
44 views

problems with displaying sfml textures

I have created a kind of framework for a game that combines box2d and sfml. All game scenes are stored in the Game class. The scenes also contain information about static and dynamic objects: ...
1 vote
1 answer
52 views

How can I assign a World.createBody to a variable after initialization, `var` and `val` don't work?

...
1 vote
1 answer
986 views

How do I correctly use userData in Box2d?

Many guides used userData. But with the source of Box2d I have, I don't see the SetUserData functions in the code as I see them in the guides. After understanding ...
0 votes
1 answer
74 views

Simulating a small world with Box2D

I would like to use Box2D to simulate a small world, with entity sizes around 1cm (0.01m), some smaller than that. Box2D's FAQ says twice: Your moving objects should be between 0.1 - 10 meters. You ...
1 vote
0 answers
59 views

Object stuck against an obstacle still pushes other objects away

I have an object pinned against the ground by a revolute joint. A motor on the joint makes the object spin. Sometimes the object becomes stuck pushing against a static body. When it happens the object ...
0 votes
2 answers
115 views

Collision filtering in Box2D: running out of bits

I have a physical simulation on the streets of a city. The simulation is 2D but in a few points it could develop on multiple "layers": for instance bridges or underground tunnels. I may have ...
1 vote
2 answers
140 views

Simulating a rocket out of control in Box2D

In the void of space, a spaceship releases a rectangle shaped space-torpedo. In half a second, it starts its rocket engine and goes straight until something get in its way, and then boom! The code ...
  • 88
1 vote
0 answers
210 views

Avoiding jitter when snapping diagonal movement to a pixel grid

Whats the best way to be rendering the locations of objects in box2D in such a way that there no stuttering on movement beyond 8-directions. I'm looking to have object strictly snap to the pixels but ...
1 vote
1 answer
208 views

What could effectively affect the falling speed of a b2Body?

I tried to set up a test demo to see if Box2D physics are working. It works, but I have one small problem: I cannot seem to get the dynamic b2Body to fall faster. I ...
0 votes
0 answers
64 views

Box2D calculate distance in certain direction

I'm writing simple AI genetic learning for a 2d car. To do so I need sensors surrounding my car so I can get distance to closest obstacle in every direction. (Picture 1) Picture 1: I need every of the ...
0 votes
1 answer
512 views

Way to check overlaps of a collider2d that's not set to "is trigger" in Unity

I have a system where physics2d objects are spawned and I need to know when they spawn outside of a region defined by a box collider set to "is Trigger". Using onTriggerEnter and ...
1 vote
0 answers
39 views

How to create a joint, where the rotation of one object is relative to the other?

I would like to create a top down view scene, with one rectangle (top) is on top of an other (base). There is a joint, where ...
  • 257
0 votes
1 answer
65 views

Box2d: High screen resolution / frequency causes high friction?

I'm using Cocos Creator with (built-in) box2d for physics. Recently our game behaves weirdly on our new device Galaxy S20 Ultra 5G - which has screen size = 1440 x 3200 - frequency = 120Hz. After stop ...
2 votes
1 answer
220 views

Predicting trajectory of Box2D physics body using both: linear dumping and gravity

I would like to calculate position of physics body after some time because of predicting shots trajectory in my game. I found some great answer here where Iter Ator provides equation to calculate ...
1 vote
4 answers
274 views

When an object is launched off-screen, is there any way to know if it's coming back?

In this scene, the object becomes invisible and then comes back In this scene, the object becomes invisible but does not come back Is there any way I can tell if an object will come back when it ...
3 votes
1 answer
2k views

How to develop both a client and headless server together in Unity

I'm making a multiplayer 2d shooter platformer in unity. And after studying the different options to program an authoritarian server and with the great help that many of you have already provided me ...
  • 37
0 votes
0 answers
101 views

Box2d on authoritative server for Unity client

I'm creating a multiplayer platform and shooting game in unity, using unity2d's own physics system (box2d). But the truth is that I am quite lost in the creation of an authoritative server in c ++. I ...
  • 37
1 vote
1 answer
183 views

how to set volume of sound depending on the impulse a body receives in Libgdx / Box2d?

I am trying to set the volume of a bouncing sound of a ball depending on how hard the ball hits something. so the harder the ball hits a wall or a ground the more loud the bounce sound. I couldn't ...
0 votes
0 answers
163 views

Optimizing Box2D for a couple hundred static bodies

I searched but could not find anything similar (Yet) around the web, so here I am asking my question: In my game I use around 3 to 4 hundred static bodies with like 10 dynamic bodies in the Box2D ...
1 vote
1 answer
490 views

setTransform() Box2D physics not working

It's my first time posting here! I'm working on a top-down shooter game in LibGDX and Box2D (so gravity is set to (0, 0)). At the moment, to move my character, I'm ...
  • 125
0 votes
0 answers
20 views

Body's initial velocity is too fast when created after minimax algo

I don't know if my question is right but I cannot address the real problem. I am dropping connect 4 game chips under gravity but when I apply minimax with a depth of 3, it starts with great velocity. ...
0 votes
1 answer
91 views

Box2d: crash on createBody in beginContact callback

I am getting this error on creating body in contactListener ...
1 vote
1 answer
189 views

Apply impulse in direction line is pointing with force proportional to the length of line

I have a line perpetually pointed at the mouse and originating at the player, but the length is limited to a certain value. I also can create a circular object on demand in Box2D (specifically the ...
  • 121
0 votes
1 answer
103 views

Box2d RopeJoint bug - fix or alternative solution?

What I am trying to do is to create rope game. Below you can find a movie how it looks like now. https://youtu.be/QTULCGNF70I I am using RopeJoint and I am reducing maxLength each frame to be able ...
0 votes
1 answer
125 views

Planck.js (rewritten of Box2D.js) - 8 direction box movement

I have a box in Planck.js. I want to move this box with some keys. How can I do that? My code: ...
  • 1
0 votes
0 answers
149 views

Box2d ContactListener function. Problem calling a function on the collided objects

I created a ContactListener class which derives from b2ContactListener. I am following the excellent tutorials found here: https://www.iforce2d.net/b2dtut/collision-callbacks Collisions are detected ...
0 votes
0 answers
261 views

How do I make a hitbox for a sword in a top-down game?

Context: I'm using Box2D through LibGDX in Java. The sword and the player are in separate classes. Both extend LibGDX's Sprite class. I've got a sword attached to my character that swings when I ...
  • 992
0 votes
1 answer
212 views

Box2d Raycast C++. Always returning false? (trying to check if player is grounded)

I'm trying to add Box2d to my C++/SFML platformer game. I have my ground tiles with a b2staticBody. And the player character is b2_dynamicBody. My usual method to check if player is grounded is to ...
0 votes
0 answers
155 views

LibGDX Box2D, how to play an animation once, then set the state back

So, I've got some animations in LibGDX that I want to get running. Currently, the walking animations work perfectly, but attacking doesn't. I want the attack animation to play once, then set the State ...
  • 992
0 votes
1 answer
116 views

testPoint not working - libgdx

I'm making a game like angry birds with LibGDX and box2d in which I want to drag a ball (instead of the bird) back before releasing it. I deploy with testPoint function: when I touch down the ...
0 votes
1 answer
302 views

How to damp the velocity of an object only in one axis in Box2d?

I want to damp the velocity of a ball linearly on the x-axis. but when applying linear damping on the ball, the damping also applies in the y-axis which makes it look like its floating. I tried to ...

1
2 3 4 5
17