Box2D is an open-source rigid-body 2D physics simulation library for games, written in C++, with ports in various languages
0
votes
2answers
38 views
How to create a linear plateform between two points?
I have a set of 2D coordinates. Their positions are regular on the X axis, but unpredictable on the Y axis:
I would like to create slim platform between each point in order tu use it as ground for ...
-1
votes
0answers
16 views
How to make the interaction of sensors is in box2d? [closed]
can not figure out how to make the interaction of the sensor platform has become active. something like this:
BeginContact {
if (sensorA && sensorB){
platform.getBody ()
...
0
votes
0answers
122 views
Box2dMapObjectParser isometric map - bodies have wrong position and size
I'm using Box2dMapObjectParser to load Tiled objects layer onto my IsometricTiledMapRenderer'ed TiledMap.
It works OK with a UnitScale of 1 but the position is wrong and some shapes have weird ...
0
votes
1answer
39 views
How to split a screen in half using LibGDX without scaling?
I am currently working on a racing game with libGDX and I need to split the screen in half for a two-players mode. (Player 1 in first half and Player 2 in second half).
I already have Camera1 that ...
1
vote
0answers
34 views
Best way to create defence(withdraw) algorthim libgdx?
I have created user body and enemy body. Enemy body uses the steering behavior created by gdx AI. User body have it own control inputprocessor. World doesnt have gravity.
Enemy body arrives the user ...
0
votes
1answer
35 views
Libgdx Sprite rotation around specific point
I made complex dynamic body that rotates around other body that is static. It works perfectly, however I got messed up with sprite position on that body.
Here's what I have now
and here's what I ...
0
votes
0answers
46 views
Why is my tiled map moving when I move the camera in libGDX?
I use LibGDX. I have created a map with Tiled Map Editor and loaded it to the game. Everything else is working well, but when I move the camera, the map moves: it jumps or floats.
My code:
public ...
0
votes
1answer
14 views
Box2dWeb: rotating object about a point
I am having problem rotating box2d object back and forth around a point.
To better understand my problem i have prepared an example clicking on key rotate the paddle when u click again the paddle ...
1
vote
0answers
30 views
Java Libgdx Attaching Sprite to Box2D Body
So I am working on programming a java 2D platformer for fun on the side and I have a rendered TMX level and a box2d body (just a circle shape) that I am currently using as my player. All the controls ...
0
votes
0answers
27 views
How can I simulate a basketball throw in LibGdx box2d?
So I want to simulate a similar throw like in the game Bouncy Basketball.
Do i need to create a body and attach another body on it that would be the arm and then how would I apply force/impulse to the ...
0
votes
0answers
16 views
Box2d capsule stumbles on ground
I am working on a game with box2d and sdl. I Created a character and some boxes as ground, but faced the problem where the character would run a few meters, and stumble on one of the boxes' edge. I ...
0
votes
0answers
48 views
Box2D Physics Crazy
I have a simple Box2D Game with a dynamic player, a static floor, and a matrix of gems.
The problem is that the physics engine goes crazy. You can see in this video:
https://youtu.be/iaH_ex8eVVk
...
0
votes
2answers
35 views
Sprite not drawn on the same position as its Body LibGDX after implementing Pixels Per Meter Division on Box2D
I had a problem where the sprite was not positioned on Body correctly which I solved and you can see it here:
Box2D is not positioned on the sprite correctly LibGDX
After I solved that, I needed to ...
1
vote
1answer
59 views
How to handle two players playing on one keyboard with Box2D (LibGDX)?
I'm making a racing game with LibGDX and Box2D. I've been using this tutorial to implement the basic physics, and it works properly.
My main problem is to implement two different sets of keys ...
0
votes
2answers
45 views
Box2D is not positioned on the sprite correctly LibGDX
I have a strange issue where my Box2D is not being positioned on the player correctly. Down is the picture:
What I find more strange is that the Box2D is positioned correctly on the cloud that is ...
0
votes
2answers
84 views
Why is my character passing through in Box2D?
I have a collision problem in Box2D.
I am trying to do a simple platform game with Libgdx, Box2D and TiledMap.
I have a map made with TiledMap:
I load the map in my Android game. I read all the ...
0
votes
1answer
37 views
LibGDX--constant high score in top corner
I'm currently programming a game using LibGDX and box2D. I have a sprite (player) that moves up the screen, kind of like doodle jump.
I'd like to have my camera to be centered around the player at ...
1
vote
1answer
42 views
Box2D fixed timestep updating is twitchy on constant FPS
I'm messing around with libgdx and box2d and I'm trying to implement sidescroller movement with fixed timestep logic according to the famous Fix Your Timestep! tutorial/guide. However, logic updating ...
2
votes
2answers
114 views
Box2DLights in libGDX - Bad quality of the light gradient on Android
I am facing a problem while porting one of my libGDX project from desktop to Android : My game uses Box2DLights. While the light effect look very fancy on the desktop version of the game, it looks ...
0
votes
0answers
36 views
How to Implement a 2d camera object for a side scroller game
Ok so Heres the problem. I'm Using c++ with sfml for graphics and box2d for physics. I've tried an ultra simple cam movement in the past where i lock the player to the center of the screen and offset ...
0
votes
1answer
30 views
Libgdx + Box2d working with 2 cameras
Recently I have read that you can work with 2 cameras whenever you involve Box2d, which only works in meters.
In my Renderer class, I receive all the entities in the game and then draw them. I work ...
0
votes
0answers
37 views
Box2D top down car weird spasm
im currently programming a 2d top down racing game with box2d and libgdx.
i have a car body to which there are 4 wheels attached. these 4 wheels are attached with RevoluteJoints ( for the front ...
3
votes
1answer
62 views
Problem merging vertices of two polygonial bodies
SUMMARY
I need help to create a weld joint that fixes the two bodies together in a way as illustrated in the first image.
ISSUE
I am having an issue where I cannot find out how to weld vertices of ...
1
vote
3answers
196 views
Box2d set sprite to body that rotates around specific point
I want to rotate kinematic body around a specific point (I already done this part using
shape.setAsBox(1.8f / PPM, 0.2f / PPM, new Vector2(5.2f, 0), 0);
What I try is this:
PolygonShape shape ...
0
votes
0answers
69 views
Box2d - Texture lagging and flickering
I'm having issues with texture rendering in my game. I've done a lot of research and repeated the same steps of tutorials over the internet to render and update Sprite positions properly. Somehow, ...
0
votes
0answers
57 views
Libgdx and Box2D TiledMap render is not smooth
I'm building simple side scroller game. My player (square) move fast and it interacts with other world objects. Problem is when my player is moving it seems that all world is rendering somehow strange ...
0
votes
2answers
42 views
Libgdx box2d bodies go through other bodies
I'm developing a game using libGDX and box2d. I am facing a problem that bodies go through each other... I'm moving the body using a TouchPad by setTransform. I think the problem is that I use ...
0
votes
0answers
19 views
LibGDX: Is there any way to check if space between 2 bodies is free?
I know how to calculate the distance between 2 bodies in my game using Math.hypot(x,y); but I need to know if between those bodies the space is free, I mean, without any body.
0
votes
0answers
34 views
LibGDX & Box2D Actor Collision
I'm working on a LibGDX project, and I was wondering about the best way to define actors in a collision. I know this is probably a common question, but specifically I'm interested in beefing up one ...
0
votes
0answers
31 views
ChainShape in Box2D
I recently began to learn libgdx and I am stuck at a problem with the CainShape of Box2D.
My first goal is to simply create a box with a ChainShape.
In order to achieve that, I added four Vector2 ...
0
votes
0answers
23 views
Libgdx moving a body sequence
How can I move a body (box2d) to different points in an order. Like first it moves to 100,200 then to 200, 450 and so on? I've tried actions(and actor) but I can't get the point where the body is ...
1
vote
1answer
71 views
LibGDX Box2D texture on dynamic generated body
I'm creating a game that is similar to hill climb racing. I've generated the ground and now I want to add texture to the ground. Here is a screenshot of a game
Here is my code (I create ground using ...
0
votes
0answers
36 views
libgdx box2d car wheel circle collision with ground
I'm creating game similar to hill climb racing. I have created car (which is basically polygon with two circles) and ground generated by sinus. Now here is the problem: when my car try to climb in ...
1
vote
1answer
43 views
Libgdx Box2D random positions and intervals falling bodies
I need to make that objects fall from the top of the screen random intervals and positions. Here's my code where I create lot of objects and add them to ArrayList
private void createBalls() {
...
1
vote
1answer
52 views
Problems managing collision filtering
I have my character fixture and body(is a tank), so when I press the screen it throws a rocket(which also has a body and a fixture) that the player can controlll touching the screen. My game also has ...
0
votes
1answer
56 views
How to make a ball hit many tiled circular objects in LibGDX
Hey guys I've been learning to make games with LibGDX. I did a tiled map in Tiled and the rest of code in java using Android Studio. I could make a ball bounce on the flour using Box2D, but I can't ...
1
vote
1answer
24 views
Box2d How to connect distance joint to the ground?
I have a rectangular fixed size world. I want to connect a body inside it to any place(near that body) in the world with a b2DistanceJoint. Do I need to create a large static body with the size of the ...
1
vote
2answers
75 views
Box2D LibGDX Body.getPosition() and Body.getWorldCenter() problems
I have a problem with my game in Java with Box2D and LibGDX
I found out that when I use
body.getPosition() it is only half of that of body.getWorldCenter().
The problem here is for me that I use ...
1
vote
0answers
24 views
Movement for Box2D Bodies
I'm having trouble wrapping my head around something that should be relatively simple. I'm making a breakout clone using LibGDX and Box2D. I'm also using the Ashley ECS. For movement with bodies, I ...
1
vote
0answers
59 views
Moving box2D body with texture?
I was following the solution from this http://stackoverflow.com/questions/20180063/box2d-body-with-texture. I ended up getting this working for static bodies. But when trying to get the PolygonSprite ...
0
votes
0answers
69 views
How to dynamically draw a filled polygon with a given array of vertices?
Say I have a simple array of vertices (or floats with every odd index being the X of a vertex and every even being the Y), how could I paint all the area between the vertices?
As in, I have maybe ...
1
vote
3answers
137 views
Most optimal way to load 2D world
I am creating a 2D car racing game. (Yes, a Hill Climb Racing clone)
What I am doing right now is load 10% of the map every time the user gets to 7%. For example:
Imagine the map has 10km. (10000m)
...
5
votes
4answers
96 views
Dealing with collisions across adjacent static bodies
The Problem:
I have the following setup:
A, B and C are rectangular static bodies in box2d.
p is a circular dynamic body in box2d.
The movement of 'p' is solely controlled by the current gravity ...
3
votes
1answer
40 views
Static body bridging two other static bodies
I have two box2d bodies like below,
What I need is to create another body that kind of bridges this two bodies. I am not looking for a box2d joint, but a body that will be like a bridge touching the ...
4
votes
2answers
106 views
How do I set angular velocity/torque so that it's pointing to velocity/direction?
Right now, when I spawn a shootable object, it goes like this:
Because I just set it's angle to this:
float aimAngle = (float) Math.atan2(velocity.y, velocity.x);
bullet.setBodyAngle(aimAngle);
...
0
votes
0answers
31 views
Get entity at supplied world position LIBGDX
So I'm making a simple 2D rpg. What I need is to be able to interact with the entity that the player is looking at. I need to be able to look at E.g another player in the world and press 'E' and have ...
1
vote
3answers
87 views
How do I make a box don't slide up/walk normally on a slope?
I'm trying to implement slopes in my game. When I walk up the slope and suddenly stop, here is what happens:
And when I move down, it goes like this:
I have set density to 0.5, friction to 0 on ...
1
vote
0answers
79 views
Should I compute impact damage with energy or momentum?
My game uses physics (Box2D in particular). Just about every object in the game can be destroyed, and the primary method of combat is by slamming objects into one another at high speed. It makes ...
0
votes
0answers
71 views
LibGDX Box2DLights - Global Illumination
I'm using LibGDX + Box2D to create dynamic lights in my game, but I'm currently stuck. I'm trying to light up every game object in the game with its own shadow, kinda like global illumination.
Do you ...
1
vote
0answers
36 views
Multiple bodies or multiple fixtures for a wall in Box2D?
I am making a game with a sort of "playfield" where the game takes place, acting as boundaries on a top-down shooter. I am using Box2D for physics, and I am questioning which of the following would be ...