We’re rewarding the question askers & reputations are being recalculated! Read more.

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
42 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
11 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
25 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
70 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
80 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
48 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
41 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
46 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
22 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
49 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
14 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
54 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
35 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
17 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
22 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
60 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
106 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
36 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
83 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
149 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
50 views

Libgdx Box2d TiledMap Scaling

I think I'm doing something completely wrong but I just can't seem to wrap my head around the box2d pixels per meter conversion. Currently I have a Tiled map with an object layer I want to use as my ...
1
vote
1answer
53 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 ...
0
votes
0answers
33 views

Box2D LibGDX Cant Create ChainShape Static Body in server side with same position client side

I am trying to create walls in server side which i have already created in client side.This is how i create them in client side: ...
2
votes
1answer
146 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
32 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
124 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 ...
0
votes
0answers
30 views

Libgdx Box2D Triangle Joint behaviour

I have 3 Bodies (Nodes) that are connected in a triangualr shape using DistanceJoint's (Muscle). I'm increasing the length of the bottom Muscle(m). At a given point the "triangle" collapses and all 3 ...
3
votes
1answer
107 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
49 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 ...
0
votes
0answers
53 views

Mirror effect on isometric map

I'm trying to make an isometric game with LibGDX and Box2D for collisions. The map and collisions lines are made in Tiled, but when transforming orthogonal coordinates to isometric with this code I ...
0
votes
1answer
167 views

LibGDX Box2dlights - Body Shadow Problem

While playing around with the box2dlights with libGDX, I have managed to get it all up and running, but have a problem with the shadow rendering. This is what I currently have atm: With the lighting ...
1
vote
2answers
211 views

How do I implement efficient collision avoidance in 100 enemies

I am developing a libgdx game. It is a top down shooter and I am trying to make a good AI. I have tried to implement A* from the AI library from libgdx and it works fine but when i have a lot of ...
3
votes
1answer
205 views

What is the physics behind a 2D gravity tunnel?

In Portal 2, there is a concept of an "excursion funnel", a beam of light that moves physical objects in a certain direction. Here is a link to a demonstration. I added a simple implementation that ...
1
vote
1answer
232 views

How to implement a camera for a TiledMap with SDL2 and Box2d?

I m writing a game engine using mainly SDL2 and box2D, I implemented TiledMap class that loads a tmx map and everything is fine it even support animation and objects that later will generate Box2D ...
2
votes
1answer
51 views

How to make a motorcycle running on a vertical circular track(loop-da-loop) without falling down due to gravity?

I am currently developing a game, motorcycle type game. Of course, my map is not just made up of simple line or curve. For example: a vertical circular track in the map. i've seen most 2D motorcycle ...
0
votes
1answer
136 views

How do I set the gravity of a plane world

As you can see in the image, the character is set to move on a ground plane, however that causes an issue with Box2d's gravitational pull. The player can go sideways, upwards and downwards on the ...
4
votes
2answers
322 views

Top-down conveyor belt with Box2D

I'm trying to code a conveyor belt for a project made with LibGDX and Box2D and I would like to make it like this one from Bomberman Land Touch. As you can see, the entities standing on it should be ...
0
votes
1answer
87 views

How can i collide two bodies without filtering(collision filtering)?

I have two bodies with fixtures. One is platform or ground and other is the player itself.I want to collide the player to the platform without bit filtering.How can i do that?I can see the rectangular ...
0
votes
1answer
132 views

Does destroying body also destroys the sprite?

Suppose a sprite is attached to a box2d body. And world.destroyBody(b); is getting called then the sprite also get destroyed or it stays there in memory. In my ...
1
vote
1answer
339 views

How to set a box2d body to follow a strict path

I'm making an infinite runner type game and I want one of my enemies (when it's created) to swoop down in a sort of U motion where it'll hit the player if they don't react quick enough once the enemy (...
0
votes
1answer
338 views

How to remove horizontal black bar at the bottom of the game screen in libgdx?

Here is the screenshot .Here is my Play constructor in Play class.
0
votes
1answer
148 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
2answers
669 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/...
3
votes
1answer
239 views

Is there a “Least Terrible Method” for sharing Entities over Network?

(Preface: Using C++, Box2D, and built UDP client and server classes that are reasonable efficient for a built-from-scratch game using client-server model.) This question is specifically in regards to ...
1
vote
1answer
294 views

Simulate wind affecting a boat using a 2D physics engine like Box2D or SpriteKit?

I'm looking for a way to simulate the forces created by wind and how it affects a boat. In a nutshell: if wind hits a boat (sailing yacht), the bow is aligning with the wind and if the wind is strong ...
0
votes
2answers
144 views

Why is the sprite so offset from the physics body?

I'm trying to make a sprite object that has physics, but once the game runs the physics body is drawn at an unknown offset from the sprite, which varies based on the size of the sprites texture. ...
0
votes
1answer
43 views

Box2D and OrthographicCamera working incorrectly

I'm trying to build a simple game where TileMapRenderer renders a labyrinth, a ball moves in it and camera follows it. I'm currently having the following bug: For some reason, the game renders the ...
1
vote
1answer
95 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
1answer
108 views

Drawing Explosions Respecting Walls

I am creating a tiled game (2D top down) and I created explosions working this way: The blue lines are walls, the white grid is accessable space. The red dot is the origin of the explosion with the ...
1
vote
1answer
173 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)....