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
1answer
48 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 ...
0
votes
1answer
213 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 ...
0
votes
1answer
174 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: ...
3
votes
1answer
220 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 ...
3
votes
1answer
63 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
2answers
128 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
33 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
85 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
0answers
40 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
1answer
25 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 ...
0
votes
0answers
43 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 ...
0
votes
1answer
116 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
518 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
172 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
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
416 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
27 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
1answer
181 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
1answer
324 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
833 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
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
1answer
73 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
273 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 ...
1
vote
1answer
33 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 ...
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), ...
2
votes
3answers
6k views

How to get width and height from a body in box2d?

I am working on a game in Libgdx framework. I have to get width and height from a body in box2d. is their any way to get width ...
0
votes
0answers
15 views

Unable to rotate box2d body with torque if revolute joint introduced

I created a simple body (PLAYER) which, as speed increased the angle of the body increases slightly. I set the torque property based on velocity, to change the body's angle, and it looks like the ...
0
votes
0answers
19 views

Can problems arise in client-server network games due to the permanent sending of messages?

I'm my Client-Server-based game I'm using the following stack: libGDX (Engine) Ashley (ECS) KryoNet (Networking) Box2D (Physics) Server =========> Client I've got a Box2DSyncSendingSystem on ...
0
votes
1answer
52 views

Box2d RopeJoint bug - fix or alternative solution?

What I am trying to do is to create rope game. Below you can find a movie how it looks like now. https://youtu.be/QTULCGNF70I I am using RopeJoint and I am reducing maxLength each frame to be able ...
4
votes
1answer
1k 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 ...
0
votes
0answers
16 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. ...
0
votes
0answers
17 views

Pouring balls into a shape to fill it densely

I am trying to making a physics game similar to Angry Birds Dream Blast (ABDB), using box2d. I need to fill the play field with balls/chips. Problems: I have a few of them: I do not understand how ...
0
votes
1answer
33 views

Box2d: crash on createBody in beginContact callback

I am getting this error on creating body in contactListener ...
1
vote
1answer
34 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 ...
0
votes
1answer
71 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
0answers
20 views

Planck (rewritten of Box 2D) - Two sensor collide

I want to print "on" when two sensors collide. This code is printing "on" in any fixture collide. I just want for 2 sensors. ...
3
votes
1answer
283 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 ...
0
votes
0answers
48 views

Box2d ContactListener function. Problem calling a function on the collided objects

I created a ContactListener class which derives from b2ContactListener. I am following the excellent tutorials found here: https://www.iforce2d.net/b2dtut/collision-callbacks Collisions are detected ...
0
votes
0answers
103 views

How do I make a hitbox for a sword in a top-down game?

Context: I'm using Box2D through LibGDX in Java. The sword and the player are in separate classes. Both extend LibGDX's Sprite class. I've got a sword attached to my character that swings when I ...
0
votes
1answer
78 views

Box2d Raycast C++. Always returning false? (trying to check if player is grounded)

I'm trying to add Box2d to my C++/SFML platformer game. I have my ground tiles with a b2staticBody. And the player character is b2_dynamicBody. My usual method to check if player is grounded is to ...
0
votes
0answers
33 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
22 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 ...
11
votes
5answers
1k 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
1answer
47 views
1
vote
0answers
33 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
98 views

Assertion b2Assert(m_bodyCount > 0) showing an error

I have the following code for deleting a Box2D body: ...
0
votes
0answers
40 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),...
0
votes
1answer
112 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
103 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 ...

1
2 3 4 5
16