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
13 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
25 views

Box2d: crash on createBody in beginContact callback

I am getting this error on creating body in contactListener ...
1
vote
1answer
31 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
49 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 ...
0
votes
0answers
17 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. ...
0
votes
0answers
9 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
0answers
42 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
77 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
52 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
29 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
21 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
37 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
38 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 ...
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
1answer
43 views

How do i draw sprite on fixture position?

...
0
votes
2answers
82 views

Assertion b2Assert(m_bodyCount > 0) showing an error

I have the following code for deleting a Box2D body: ...
0
votes
0answers
19 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
28 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
98 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
22 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 ...
0
votes
3answers
77 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
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
18 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
62 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 ...
0
votes
1answer
67 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
0answers
50 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 ...
1
vote
0answers
202 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
88 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
1answer
68 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. ...
0
votes
1answer
88 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
2answers
94 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
0answers
37 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
92 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
0answers
29 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
164 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 ...
0
votes
0answers
70 views

Box2D - Proper way to simulate player's body and feet

I'm new to LibGDX and Box2D, and I'm trying to create my player's body but got some issues. I've created the ground as a ChainShape, and my player as a Rectangle. I want to attach a fixture for its ...
0
votes
0answers
19 views

Best practice for frequent sending webSocket/Socketio/webRCT data [duplicate]

I already done game template for classic platformer. I use matter.js for physics and my own override draw functions. Everything works fine. Next stage is to make it multiplayer. I interest is it good ...
0
votes
1answer
30 views

LIBGDX - Artifacts when scaling background image

I've got a problem with libgdx. First off, im working with libgdx and box2d on a little physics game. Im using the aproach mentioned in this answer and thereby setting my camera to some smallish ...
1
vote
0answers
65 views

Is it better to combine or leave alone 2D polygons

I'm making a modular system for a 2D spaceship arcade like game, the user builds their own ship with equilateral triangles to make more complex shapes. When the ships are small it's no problem, but as ...
0
votes
1answer
128 views

PyBox2D car moves uncontrollably

I am trying to program TopDown Car using python and Box2D (similar to this tutorial: http://www.iforce2d.net/b2dtut/top-down-car ) The steering is so far limited to thres states of wheel rotation, ...
1
vote
1answer
47 views

Unexpected output from the merging of a quadtree, when that data is converted to Box2D fixtures

I've been staring at this code trying to troubleshoot this for the past 3 days, but I seem to have gone Code Blind. I KNOW the issue is stupidly simple, but I just can't crack the problem. I'm using ...
0
votes
1answer
154 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 ...
3
votes
1answer
236 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 ...
1
vote
1answer
67 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 ...
2
votes
1answer
277 views

Box2D physics are different on server and client

I'm using C# Box2D library for my server and client, they have similar world.step(), iterations and update function. At the same time they have different physics' results, difference is not fixed, it ...
1
vote
0answers
35 views

How to differentiate between colliding objects in Box2D?

I need to differentiate between different points of contact in my racing game. I currently have staticSensors which determine if the car is on the track or not, but I have created a second sensor to ...
1
vote
2answers
222 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 ...
3
votes
1answer
177 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
1answer
53 views

Rotate object around a dynamic object

I'm trying to rotate an object (shield) around another object (player) like this question. My use-case is this: I have players moving around a field. Their respective shield is orbiting in a constant ...

1
2 3 4 5
16