Questions tagged [box2d]
Box2D is an open-source rigid-body 2D physics simulation library for games, written in C++, with ports in various languages
817
questions
0
votes
0
answers
57
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
0
answers
37
views
How detect collision between object1[i] and object2[j] then do something with them in Box2D games?
I am making a simple game with Box2D and SDL2. I have GameObjects vectors for example: 1.vector of Enemy 2.vector of Bullets…
in ContactListener class i can detect collision between enemyFixture and ...
0
votes
1
answer
47
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
52
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
48
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
58
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 ...
0
votes
0
answers
22
views
libGdx Box2d Sword
Is there a good way to use libGdx Box2D as the main library for a rogue-like game? I want so items could be picked, dropped, and when they are picked to be a separate part of character (I tried ...
3
votes
1
answer
148
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
71
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 ...
0
votes
0
answers
86
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
64
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
164
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
50
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
209
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
136
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
70
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
114
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
113
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
71
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
51
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
101
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
77
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
58
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
100
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
64
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
249
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
359
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
136
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
102
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
296
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
133
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
58
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
58
views
2
votes
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 ...
0
votes
1
answer
117
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
96
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
238
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
200
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
371
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
477
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
102
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
2
answers
876
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
78
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
82
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
355
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
434
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 ...
4
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 ...
0
votes
0
answers
139
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 ...
1
vote
1
answer
284
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 ...
1
vote
0
answers
321
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 ...