Questions tagged [box2d]
Box2D is an open-source rigid-body 2D physics simulation library for games, written in C++, with ports in various languages
821 questions
1
vote
1
answer
111
views
Objects move with different speed on different devices
I was making a 2d top-down game, but when I tested it on two devices (Samsung M31 and Samsung S25) there was a problem with player speed - it was faster on S25 and slower on M31. I tried using some ...
0
votes
1
answer
142
views
Can't make circles collide using Box2D
I'm completely new to Box2D. I'm implementing some tests with Raylib. I managed to implement the collision between static and dynamic rectangles and now I want to insert circles into the simulation, ...
0
votes
1
answer
113
views
How to drag existing body to another position?
I have a game object with a Kinematic body and a sprite. The object's "draw" method will always position the sprite to match a position of actual body, so the sprite is completely passive.
...
0
votes
0
answers
39
views
Unity continuous collision jitter issue
I have about 100 circle colliders set to dynamic/continuous. They're all being dropped into a "hopper" at the start of the level.
I've noticed that this is:
A) Tremendously expensive (as I ...
0
votes
0
answers
74
views
How to Simulate Natural Falling Behavior for Stacked Shapes?
There is a thin, long rectangle placed slightly below a circle, and I let them fall simultaneously. When they hit the ground, they land perfectly aligned, one on top of the other.
In the real world, ...
0
votes
1
answer
236
views
What does the phrase "Kinematic bodies do not collide with other kinematic or static bodies" mean?
What does the phrase "Kinematic bodies do not react to forces and only collide with dynamic bodies" mean?
Related: I'm always confused by game engine physics explanations
I found this ...
0
votes
1
answer
88
views
How to destroy/remove Texture after collision in java box2d
I'm coding a simple Arkanoid/Breakout game and have problems with removing the bricks. I'm able to destroy the body but the texture is still there. I'm a beginner so is there a simple way to remove it ...
0
votes
0
answers
129
views
Box2d into opengl/opengl es?
I recently learned a little bit of OpenGL through learnopengl.com. I've got through the window, gone through the triangle, then shaders along with interpolation, textures, and now transform. When I ...
0
votes
1
answer
90
views
Connecting bodies together in jbox2d
Im trying to connect bodies together to make some sort of a "building" system or more specifically im trying to make multiple "blocks" connect to eachother but Struggling to figure ...
1
vote
0
answers
71
views
Outline Position in pool game
I'm developing a pool game using SFML and Box2D, and I'm currently facing an issue with creating the cue ball outline when the player aims. I have three rays that are cast: two black ones and one ...
0
votes
1
answer
113
views
How to make a ball always bounce like in the game One More Bounce using Box2D?
I'm coding a game with Flutter and the flame_forge2d package (which uses Box2D internally). I want to make a game whose principle is similar to that of the game One More Bounce (a game where you have ...
0
votes
1
answer
99
views
How to save score without resetting to 0 between Game Scene and Pause Scene?
I'm currently working on a LibGDX Java Game Project inspired by the Space Invaders game where I have created 2 Scene Classes: LevelScene and ...
3
votes
1
answer
182
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 ...
0
votes
0
answers
124
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 ...
1
vote
0
answers
89
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. ...
0
votes
1
answer
208
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 ...
0
votes
0
answers
80
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 ...
0
votes
1
answer
286
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 ...
0
votes
1
answer
248
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
...
2
votes
0
answers
104
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
150
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 ...
1
vote
1
answer
178
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 ...
0
votes
0
answers
117
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 ...
1
vote
0
answers
63
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
123
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 ...
0
votes
1
answer
95
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 ...
0
votes
1
answer
79
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 ...
0
votes
1
answer
147
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
98
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
313
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
443
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
210
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
146
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) ...
0
votes
0
answers
375
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 ...
2
votes
0
answers
178
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
73
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
102
views
2
votes
1
answer
3k
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
157
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
126
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 ...
1
vote
2
answers
401
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
255
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 ...
1
vote
0
answers
447
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
594
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
127
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
3
answers
1k
views
Way to check overlaps of a Collider2d that's not set to "is trigger" in Unity
I have a system where 2D physics 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 ...
1
vote
0
answers
88
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 ...
0
votes
1
answer
101
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
437
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
516
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 ...