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
0answers
7 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 ...
0
votes
0answers
20 views

Is there an algorithm for making tiles in a tilemap join each other as regions? [duplicate]

I have a tilemap, which consists of references to kinds of tiles that are stored by coordinates, so that tilemap[x][y]=tiletype. I'm using Box2d to be specific, so ...
0
votes
1answer
58 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
0answers
15 views

testPoint not working - libgdx

I'm making game like angry bird by libgdx and box2d In that, I want to drag the ball (similar bird) back before release it. I deploy with testpoint function: when i touchdown to the screen, I will ...
3
votes
1answer
139 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 ...
0
votes
2answers
72 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? ...
0
votes
1answer
17 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
1answer
75 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 ...
3
votes
1answer
184 views

Predicted trajectory becomes less accurate in a side-on collision

In my 2D billiards game, I have it so that when the user clicks and drags with their mouse, a Physics2D.CircleCast is projected from the cueball to wherever the mouse is. If the circle happens to hit ...
11
votes
5answers
949 views

Ledge climb animation and movement (2d platformer)

Struggling to make a decision on the implementation of a ledge climb mechanic for a physics driven 2d platformer. What is the best way to go about this without it getting overly complex? So far I ...
0
votes
0answers
13 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 ...
0
votes
1answer
99 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
2answers
401 views

Strange LibGdx box2d body.ApplyLinearImpulse(); behavior

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
1answer
149 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 ...
4
votes
1answer
833 views

How can I generate vertex data from an SVG?

I am trying out the Phaser game engine, and am interested in making a vector graphics game (simple black and white like Asteroids), but I want to use vector graphics instead of raster PNGs. I was ...
2
votes
1answer
1k 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: ...
1
vote
1answer
251 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, ...
0
votes
1answer
39 views
1
vote
0answers
30 views

What would be the best way to let Box2D handle collision on different (simulated) heights?

I'm working on a 2D top-down game but we are also using a Z coordinate. This is to simulate the effect of 3D/height. Now the player can walk under a bridge and also over a bridge. The next thing I did ...
0
votes
2answers
69 views

Assertion b2Assert(m_bodyCount > 0) showing an error

I have the following code for deleting a Box2D body: ...
0
votes
1answer
161 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 ...
0
votes
0answers
12 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),...
1
vote
1answer
216 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
1answer
778 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
1answer
62 views

Why is my client's body drifting even after using data from the server, and how do I fix it?

I am trying to use Box2d on nodejs server with libGDX client. What I am trying to apply is authoritative server model so clients are just sending input data to server, server is running simulation and ...
1
vote
2answers
3k views

Box2D : rotate and set position to a static body with another origin

I try to rotate a static body of a PolygonShape, from another origin, and set the position regarding this new origin. Why ? Because I create bodies from ...
1
vote
2answers
160 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 ...
5
votes
1answer
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
1answer
32 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 ...
0
votes
3answers
64 views

Finding an angle between two bodies

I am trying to find angle between vectors a and b. But the cosine for some reason is not within +/- 1, that means that it is not possible to find an angle between a car and a pedestrian... Any help ...
0
votes
1answer
46 views

What scaling system to use in Box2d?

I'm worried about this Caution box from the Box2d manual: Box2D is tuned for MKS units. Keep the size of moving objects roughly between 0.1 and 10 meters. You'll need to use some scaling system ...
0
votes
1answer
15 views

how to apply force/impulse perpendicular to the moving direction in box2d

How can i apply or impulse to an object perpendicular to its moving direction in a top down game. Like if object is moving up, i press left or right, then force or impulse should be applied to left or ...
7
votes
5answers
28k views

How do I destroy a Box2D body on contact without getting an IsLocked assertion error?

I get this error when attempting to remove a body from the world: java: /var/lib/hudson/jobs/libgdx/workspace/trunk/gdx/jni/Box2D/Dynamics/b2World.cpp:134: void b2World::DestroyBody(b2Body*): ...
0
votes
0answers
18 views

How to sync Box2D worlds with an dedicated server?

My game consist of two parts: The client and the server. At first the game was planed as single player. After a few month I decided to implement it as an multiplayer game so I started a new sub-...
0
votes
0answers
15 views

How to limit Box2D bodies to only be affected on 1 axis

I have a side scrolling game, where I am randomly placing trees, bushes etc.. I would like these bodies to fall ( To Align with the ground ) but not to slide. What is the best way to achieve this and ...
1
vote
0answers
61 views

Rolling a circle around a square

I am stuck on a simple Box2D task. I have a box and a ball (in top-down view so no gravity), and I would like the ball to roll around the box. Here is my code. Basically now I am trying to detect ...
-2
votes
2answers
2k views

Having trouble implementing libGDX pause

I tried to make pause button. When users click Pause button on a screen, a window came out then, game is frozen until users press continue button in the window . my code is able to pop up window, ...
0
votes
0answers
40 views

Server Side Simulation Synchronization with Client Box2d

I am running a simple box2d simulation on nodejs server.(planck.js) 2 bodies are connected to each other with distance joint and one is orbiting around another. I also have a java libgdx client with ...
0
votes
1answer
121 views

How to get collision area within a circle in libgdx

I have a ball inside of a multi-colored circle, the ball will hit the inner area of the circle like this bellow circle image And the Circle will be rotated clockwise or anti-clockwise based on user ...
1
vote
0answers
135 views

How to make a top down 2D ball rolling

I am developing a top down game similar to 8 pool billard with libgdx and box2d. How do i make a 2d ball texture look like its rolling when force is applied like this: So it feels actually 3d ? For ...
3
votes
0answers
86 views

Game runs at different speeds in Chrome versus Firefox

I am using Box2D for physics on the server side. Player position is updated on the server, so there is nothing the client can do except give input. But running game in Chrome only, the player moves ...
0
votes
0answers
64 views

Box2D with SDL2 not working properly (Collision without rotation and problems with MKS)

I already have some expirience using SDL2 so I thought I will add a Physic Engine to my game - I chose Box2D. I managed to setup everything and to build a small program using SDL2 and Box2D. But now ...
0
votes
1answer
58 views

Box2D Weird collision behavior

I'll let the gif speak first. As you can see, the small cube just kinda floats there like it has a forcefield. This weird glitch only happens with small cubes, smaller than 60 pixels for some reason. ...
2
votes
2answers
880 views

What does linearDamping mean in Box2D?

If I set linearDamping on a body, it's velocity will be decreased slowly, until it stops. The documentation says, that the units are 1/time, which is unclear for me. If the velocity of a body is 10 m/...
2
votes
1answer
1k views

Why might a body suddenly stop while moving on continue platform?

I have a 32x32 sprite and I make some to be platform like this ...
0
votes
2answers
1k views

How to fix the sprite that is not drawn on the same position as its body after implementing pixels-per-meter Division?

I had a problem where the sprite was not positioned on Body correctly which I solved and you can see it here. After I solved that, I needed to divide everything by PIXELS PER METERS so that I can ...
3
votes
1answer
2k views

How to create a projectile motion of a cannonball in top down view?

Objective To move the bullet with projectile motion to specific destination by touch point. In the below image is an example of a bullet which has a projectile motion. On my observation, the bullet ...
0
votes
0answers
28 views

Dealing with ghost vertices of Kinematic bodies in Box2D

I'm using LibGDX and Box2D and I want to have multiple falling platforms in a row which will fall sequentially as the player runs on them, like in the picture below. (the shapes are parsed from Tiled) ...
0
votes
0answers
20 views

Libgdx Touchpad Edge Detection

I have implemented an on-screen touchpad that controls my player shape. I can move the player based on the changes on the touchpad knob using the ChangeListener ...
0
votes
2answers
102 views

Box2d: Destroy body or setActive to false?

What is better practice when a body goes out of screen, to destroy the body or just setActive(false)? I guess in terms of memory it is better to destroy it and free the memory, but is destroying ...

1 2 3 4 5 16