2022 Developer Survey is open! Take survey.

# Tag Info

Accepted

### How can I simulate a floating character in Box2D?

UPDATE: over the years I've become a bit more knowledgeable, and I realized Setup 2 can be modeled in a simpler way. I've added Setup 3, which I believe is the best solution. Your question inspired ...
• 1,685
Accepted

### How do I turn an image into a Box2D physics object?

I tried this. It was hard, but I did it. Left is GIMP, top-right is a Box2D debug renderer, bottom-right is a build shell Code repository for reference The full code is on github here. It's ...
• 13.3k
Accepted

### Why do my game objects jitter when moving the camera?

Ok, that's awkward. My last edit revealed the answer to my problem (that I've been struggling with all day): QGraphicsView casts the camera x/y position to integers....
• 285
Accepted

### What does linearDamping mean in Box2D?

I worked out a closed formula to calculate the velocity v' after some elapsed time t with a given linearDamping ...
• 247
Accepted

### Maintaining velocity of free fall body using Box2D in libGDX

Disclaimer: I have not used libgdx or Java before, this answer borrows syntax from the question and official documentation, and the code is untested To make the bodies 'fall' under the influence of ...
• 1,685
Accepted

### Movement and rotation of bodies in top down game

Simple Solution If you want the body to instantly rotate just call Body::setTransform and pass the current position and the desired angle, don't bother applying ...
• 1,685
Accepted

### Box2D recommended step, velocity and position iterations

First of all, if you want to avoid aliasing problems, you need to respect the Shannon rule. So you need to take 120FPS or more. Secondly, you don't really need to care, you can simulate at 40 if you ...
• 2,343
Accepted

### Why is Euler integration sometimes preferred over RK4 even if RK4 is more accurate?

It's very probable that Erin Cato subtly justified the use of the Symplectic Euler over RK4 or another higher order integrator. The author has lots of slides and/or material (e.g. http://gamedevs.org/...
• 3,221
Accepted

### b2DistanceJoint with frequency equal to 0 vs b2WeldJoint

Thanks for asking Narek. I've struggled with understanding these joints in the past, and I'd like to use this answer to clear up some misconceptions. ...
• 1,685
Accepted

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

From wikipedia: $$d=\frac{v_0^2}{g}sin(2\theta)$$ When you reverse the formula to find the angle from the distance and initial speed, it becomes: \eqalign{ d&=\frac{v_0^2}{g}sin(2\theta) \\ ...
• 4,856
Accepted

### How to develop both a client and headless server together in Unity

Myself, I'd recommend keeping the server and client authored in a single Unity project. This minimizes the chance for mistakes where you change something in either the server or client and miss ...
• 112k

### how do I create a moving type of block like in Mario[box2d]

I tried it out in RUBE and the Prismatic joint works fine for me: What you may not have realized is that you can set joint limits on the prismatic joint, which makes this a lot easier to set up. You ...
• 1,685
Accepted

### How to optimize a box2d simulation in action game?

Now that I think about it some more, there may be a way. Basic Idea You say you are using a tile-based map, so you might consider implementing tile-based collision detection far away from the player....
• 1,685
Accepted

### LibGDX Box2DLights shadow offset problem on bodies

This is less a problem with Box2dLights, and more a problem with setting up Box2d collision fixtures to match your sprites. The Box2dLight rays are colliding with the CircleShape fixture you attached ...

### box2d rendering performance degrading extremely even with sleeping bodies?

Yet having these 3500 sleeping static bodies degrades performance to such a degree that even when running the game on my MacBook Pro 2012 in a Genymotion emulator, I get about 5 FPS. As Anko said in ...
• 41.3k
Accepted

### In Box2D, what exactly does a fixture represent?

Yep, sounds right. A body abstractly represents a physical entity. A fixture defines its shape, physical properties and which other fixtures it collides with. Technical details in the Box2D manual, ...
• 13.3k
Accepted

### What is the physics behind a 2D gravity tunnel?

On collision with the field, set gravity to 0. While colliding with the field, multiply your velocity by a number between 0 and 1, like 0.999; This is called "damping", it simulates being inside a ...
• 591

### How to restrict jumping to a single jump?

The most common approach to this is to detect if the character is standing on a solid surface before allowing them to jump. This restricts players to a single jump since the first jump puts them in ...
• 72.7k
Accepted

### Body lost a velocity component when hitting a wall

What's happening First of all, note that this behavior is not specific to oblique collisions. Below is an example of two balls colliding head on with a wall. All fixtures have ...
• 1,685
Accepted

### How do I query a LibGDX Box2DLights "light" and "dark" regions?

I found the solution, so I think I should write here for other ones later. First I download the source code of box2dlights. Then open BaseLight.java and find "segments" member variable. This variable ...
Accepted

### Why do my Box2D bodies not fall, even though world.step is called?

1/60 in your world.Step call is an integer division, which truncates toward zero. The world is being told to step by 0 seconds ...
• 13.3k

### Java Libgdx Attaching Sprite to Box2D Body

Two (simple) solutions could look something like this: Give the player class a Sprite (best). ...
• 7,609

### What shape should you use for player collision?

Every collision shape has it's pros and cons: The axis aligned bounding box is very cheap to do collision against, but it's very rough and it's not possible to rotate it, thus it may need to be ...
• 14.5k
Accepted

### What is inertia in a physics engine?

I believe what we're looking at here more specifically refers to rotational inertia and inverse rotational inertia; not to linear inertia (nor inverse linear inertia). Wikipedia explains that ...

### Should a bowling game use a 2d or a 3d physics engine?

When developing games it is important to separate the game mechanics from the game representation on the screen. The game mechanics of bowling can be simplified to a pure 2d simulation by looking at ...
• 111k

### Turn a spaceship at a max rate

There's no friction in space so what is happening is actually the proper realistic behaviour: The ship spins faster and faster. If you want to limit rotation speed you can use Body.AngularDamping to ...
• 11.7k

### What does linearDamping mean in Box2D?

I looked at the Box2D source code, where it applies damping: v *= b2Clamp(1.0f - h * b->m_linearDamping, 0.0f, 1.0f); So the loss of velocity is certainly not ...
• 3,669
Accepted

### Predicted trajectory becomes less accurate in a side-on collision

The issue was that the radius that I inputted into the CircleCast was not accurate. Initially, I set the radius to that of the cueball's circlecollider2D, which would be .09f. But since I lowered the ...
• 680