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
1 answer
95 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: ...
0 votes
1 answer
274 views

Tuning physics for a "worms"-like game

I'm using LibGDX and Box2D for my physics but my characters bounce all over the place when moving and if there is a small slope in the terrain they launch off of it. I've tried tweaking settings but ...
1 vote
1 answer
50 views

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

...
1 vote
1 answer
515 views

Box2D simulation running slower on lower FPS(even when the desired FPS is lower than the actual)

I´m playing around and trying to make myself an easy platformer using the Box2D physics, before that I was not using it and was using my own physics implementation(just simple movements with timestep)....
5 votes
1 answer
908 views

Wheel Joint Implementation in AndEngine

I am currently developing car game in AndEngine. In which I was using revolute joint for car wheel and chassis attachment. But my friend suggest me that use wheel joint for that purpose for better ...
1 vote
2 answers
417 views

Server Side Movement Box2D LibGDX

I am trying to implement server-side movement using box2d on libgdx client and planck-js(box2d for javascript) on nodejs server. I am running box2d world on both client and server. Before server i ...
8 votes
1 answer
1k views

LibGDX Box2D Lights - Illuminate background

I have a box2D world made of tiles. I use a custom DirectionalLight for light up the scene from above (It shines through transparent blocks [eg.: the water] more deeply). The problem is (as expected), ...
0 votes
1 answer
41 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
39 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&...
1 vote
1 answer
241 views

Box2d punch detection

So working on a 2d fighting game and wondering whats a good method for detecting punch collision. Ive got a few questions on how to implement the attack stuff. Im using box2d (and Libgdx) for the ...
2 votes
1 answer
2k views

Drawing Shape in DebugView

As the title says, I need to draw a shape/polygon in Farseer using debugview. I have this piece of code which converts a Texture to polygon: ...
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
46 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
1 answer
596 views

How do make a box collider align with a line renderer continuously?

I am having the issue of aligning my BoxCollider2D with my linerenderer. I am trying to have a laser shoot using: ...
0 votes
1 answer
253 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 ...
3 votes
1 answer
435 views

Rendering Tilemap Tile Layer Side by Side for Infinite/Endless Runner Game

I was strugeling this for days how to implement tilemap into libgdx and box2d with infinite/endless scheme. I can load a single map and display everything on screen. But placing 2 or more tilemap side ...
12 votes
3 answers
4k views

How do you do AI path following within a 2d physics engine like farseer/box2d?

I'm in the process of moving a 2d top down game I've been working on into a proper rigid body physics engine like Farseer. Up until now, I had just hacked together my own physics code where needed. I'...
1 vote
2 answers
328 views

Disposing objects when changing screens

I'm making my first game with LibGDX and Box2D, and I've realized that the memory used increases when I change screens. It starts from 150MB and progressively reaches 850. How should I deal with this? ...
7 votes
3 answers
1k views

How do I duplicate a Box2d simulation, mid-simulation?

I want to serialize the state mid-game, send it over the network to an identical computer (same CPU, same OS, same binary), load it there, and have the two games run in tandem doing the exact same ...
0 votes
1 answer
92 views

LibGDX “EXCEPTION_ACCESS_VIOLATION” error when recreating previously disposed Box2DLights light

I just installed the Box2DLights dependency for LibGDX and I added a cave with 2 ConeLights inside. The first time I render the cave, everything works as expected. Then when I exit the cave, I make ...
0 votes
1 answer
100 views

Have body resume constant velocity after collision

I want to have a body move at a constant velocity, but react to collisions. My example game is a train, I want it to move at 1 meter a second. If an obstacle appears on the tracks, I want it to react ...
0 votes
1 answer
175 views

What is the correct way to get the starting point of a Box2D body?

when I use getPosition() I get the center point of the body. The fixture's position in the body is relative to the body. However if the body is inclined and has an ...
3 votes
2 answers
701 views

Strange LibGdx box2d body.ApplyLinearImpulse(); behavior [closed]

I have been working on this game NinjaThief and when I apply linear impulse to player body it just keeps on moving. Some of the functions are still unfinished so it looks a bit messy. Here is my code:...
1 vote
1 answer
200 views

Libgdx Box2d RevoluteJoint And Attached Body Interfering With Main Body's Y-axis

I am making a 2d platformer where the character has a melee attack. To achieve this, I created a new arm body which I attached to the player's torso body (comprised of two circles). However, this ...
2 votes
1 answer
275 views

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 ...
1 vote
1 answer
670 views

Increase friction with a friction joint

I'm making a topdown 2.5D game (think the legend of zelda: a link to the past) using libgdx and box2D. to simulate friction from a topdown perspective, i've set the gravity for the box2D world to 0, ...
4 votes
1 answer
939 views

What algorithms exist for generating collision geometry from an image?

I am currently working on a game using SFML and Box2D. I am interested in generating collision geometry from the sprite data that I load into SFML. So, for example, an algorithm that would do this ...
0 votes
0 answers
36 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
21 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) ...
1 vote
1 answer
739 views

Box2d collision on isometric maps built in Tiled

I am trying to add Box2d collision to a map I created in Tiled http://www.mapeditor.org/ It all worked when I was creating standard othergraphic maps but now I have changed to isometric the objects ...
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 ...
1 vote
1 answer
957 views

Ball bouncing within polygon [closed]

I saw there are quite a number of articles and sample code regarding ball bouncing within a rectangle. Is there any articles or sample code regarding ball bouncing within a polygon? I try to look ...
0 votes
0 answers
106 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 ...
1 vote
1 answer
181 views

How to keep the value of angle between 0 and PI in box2d

In box2d, if i rotate an object multiple times in clockwise or anti clockwise direction, the value of angle ( body.getAngle() ) keeps on increasing. Like at start it is at 0 radians, then 1.57(90 deg),...
8 votes
2 answers
2k views

What causes Box2D revolute joints to separate?

I have created a rag doll using dynamic bodies (rectangles) and simple revolute joints (with lower and upper angles). When my rag doll hits the ground (which is a static body) the bodies seem to ...
0 votes
1 answer
100 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 ...
2 votes
0 answers
49 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 ...
1 vote
4 answers
211 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 ...
0 votes
0 answers
32 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: ...
0 votes
1 answer
499 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
0 answers
49 views

Compute normal of collision between two bodies, when multiple fixtures touch

I have a body made of multiple fixtures. Sometimes, when another body collides with it, Box2D detects contacts between more than one fixture. The figure illustrates this: the blue body is made of two ...
0 votes
1 answer
54 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
44 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
84 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
125 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 ...
0 votes
1 answer
56 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 ...
0 votes
1 answer
250 views

Pybox2d Collision detection explanation

Hi I am working on a PyBox2D game and it became quite complex and I need to learn about collisions, so I made this very simple script in order to learn collision setting more effectively, however I am ...
1 vote
2 answers
2k views

How do I change gravity of box2d world after world is created?

I want to modify the world of box2d after creating it, namely to change the gravity vector. Is there a way to do this?
1 vote
2 answers
308 views

Get speed from vector using box2d and javascript

I need to find the speed of an object in a game. The game is made in HTML5 with jquery and jquery.box2d. For this I can use these methods: ...
1 vote
0 answers
127 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
2 3 4 5
16