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
27 views

How do I make a proper rebound in a box with an angle different than 0

I'm using Box2D and rebounding a box whenever it hits the bottom or top of the screen. I'm using world positions here; the maximum is 20.0f which is the value of ...
IRP_HANDLER's user avatar
3 votes
1 answer
140 views

Character overlaps with static objects

I am creating a simple OpenGL C++ game. I have a main character (green box) and some static objects (red boxes) positioned as stairs. The problem is as green box is descending down the stairs, it ...
Axel's user avatar
  • 33
0 votes
0 answers
43 views

Box2d's SetLinearVelocity not working as expected

I'm working in a SFML and Box2d project, and I stumbled with a problem related to the linear velocity of bodies. I've created a simplified version of the project, and the problem still persists, this ...
BOOM's user avatar
  • 11
0 votes
0 answers
65 views

Can Box2D be configured to conserve total energy of the system?

What I want I want a physics engine that can support a few dozen balls and polygon objects interacting with each other in a closed environment. It needs to support objects rotating after collision. It ...
redmoncoreyl's user avatar
1 vote
0 answers
41 views

Trying to plot trajectory of rocket using only its current position and velocity components

I have a 2D controllable rocket for which I want to plot the parabolic motion. Additionally, the parabola should be able to change due to the thrust of the rocket accelerating it in either direction. ...
confused_aspirant's user avatar
0 votes
1 answer
114 views

How to adjust parabolic trajectory to hit the same point with the same launch angle, but faster speed?

I'm launching a ballistic projectile similar to this sample. The projectile moves from the launch point to the target point, but it's too slow. When I try to increase the speed without changing the ...
QuestionAndroid's user avatar
0 votes
0 answers
44 views

High mass bodies that are stacked on top of each other are wobbling while sitting idly in Box2D

I'm recreating the SaturnV rocket to-scale in Box2D, which so-far involves 3 very massive rectangular bodies stacked on top of each other (1-2 million kg each). Box2D advises not to use such high mass ...
confused_aspirant's user avatar
0 votes
1 answer
124 views

How to improve performance of LiBGDX Android app?

After creating a few bodies and a map with collisions, the app performance clearly goes down. However, RAM and CPU don't seem fully stuck, but the game experience is horrible nonetheless. GameScreen ...
ognevo's user avatar
  • 1
0 votes
1 answer
60 views

How to get spring effect between two bodies

I'm using Box2D 2.4.1 and trying to get a spring effect between two bodies. No matter how I change frequency or damping ratio with the Distance Joint, I see no effect.. Here's my setup ...
swee's user avatar
  • 11
0 votes
0 answers
31 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 ...
Matsor Browncoat's user avatar
2 votes
0 answers
44 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/...
Simon Zvara's user avatar
0 votes
0 answers
67 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 ...
Anuhas's user avatar
  • 31
0 votes
0 answers
106 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 ...
Ankit singh kushwah's user avatar
1 vote
1 answer
79 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 ...
YamMan's user avatar
  • 49
0 votes
0 answers
54 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 ...
Simon Zvara's user avatar
1 vote
0 answers
40 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 (...
Ankit Agarwal's user avatar
0 votes
0 answers
80 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 ...
Bagbaq's user avatar
  • 1
0 votes
1 answer
57 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 ...
Gilfoyle's user avatar
  • 111
0 votes
1 answer
48 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 ...
Gilfoyle's user avatar
  • 111
0 votes
1 answer
74 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. ...
Tal Brodkin's user avatar
0 votes
1 answer
61 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 ...
Tal Brodkin's user avatar
0 votes
1 answer
182 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&...
Tal Brodkin's user avatar
0 votes
1 answer
299 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 ...
Ian's user avatar
  • 3
0 votes
0 answers
112 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 ...
EchtFettigerKeks's user avatar
0 votes
1 answer
78 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) ...
wo_ste's user avatar
  • 11
0 votes
0 answers
239 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 ...
Mamad R's user avatar
  • 113
2 votes
0 answers
100 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 ...
Blue Nebula's user avatar
0 votes
0 answers
54 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: ...
slverwolf's user avatar
1 vote
1 answer
53 views

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

...
random person's user avatar
1 vote
1 answer
2k 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 ...
slverwolf's user avatar
0 votes
1 answer
97 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 ...
Blue Nebula's user avatar
1 vote
0 answers
86 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 ...
Blue Nebula's user avatar
1 vote
2 answers
171 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 ...
Blue Nebula's user avatar
1 vote
2 answers
180 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 ...
Alex CB's user avatar
  • 376
1 vote
0 answers
291 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 ...
Aardhyn Lavender's user avatar
1 vote
1 answer
338 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 ...
WHofstra's user avatar
0 votes
0 answers
85 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 ...
Grzegorz's user avatar
0 votes
1 answer
732 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 ...
arcadeperfect's user avatar
1 vote
0 answers
67 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 ...
Iter Ator's user avatar
  • 257
0 votes
1 answer
75 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 ...
vantrung -cuncon's user avatar
2 votes
1 answer
285 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 ...
Jiří A.'s user avatar
1 vote
4 answers
372 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 ...
Sean Carey's user avatar
3 votes
1 answer
3k 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 ...
coantia's user avatar
  • 47
0 votes
0 answers
127 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 ...
coantia's user avatar
  • 47
1 vote
1 answer
238 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 ...
Yosan Girma's user avatar
1 vote
0 answers
233 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 ...
Keksoskajoska's user avatar
1 vote
1 answer
647 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 ...
Rohan's user avatar
  • 125
0 votes
0 answers
27 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. ...
Shubham Agrawal's user avatar
0 votes
1 answer
110 views

Box2d: crash on createBody in beginContact callback

I am getting this error on creating body in contactListener ...
Shubham Agrawal's user avatar
1 vote
1 answer
247 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 ...
Allister's user avatar
  • 121

1
2 3 4 5
17