9
votes
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 ...
7
votes
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 ...
6
votes
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) \\
...
5
votes
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 ...
5
votes
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 ...
4
votes
Java Libgdx Attaching Sprite to Box2D Body
Two (simple) solutions could look something like this:
Give the player class a Sprite (best).
...
4
votes
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 ...
4
votes
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 ...
4
votes
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 ...
4
votes
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 ...
4
votes
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 ...
3
votes
Accepted
How to avoid 2d enemy to see through walls
You only need to do two things: check if there is line of sight (raycast between the player and enemy) and if the angle of that ray is within the field of view (using atan2 to get an angle or using ...
3
votes
Getting Bodies to go "Super Fast" in Box2D
I see that there is already an accepted answer to this question. While it is in my opinion a helpful answer, it is not an answer to the original question of how to get bodies to go "super fast" and it ...
3
votes
Should I compute impact damage with energy or momentum?
You could use both, depending on case and need. Both are valid and both occur together.
The difference in your case is apparently how you define loss of energy, ie. what is more convenient and ...
3
votes
Accepted
Creating a player that can hold different items
I'd say, don't sweat it. Your character's two hands are independent of one another, the two items groups have distinct interfaces and are meant to be used in different ways. Just use a properly-typed ...
3
votes
How does mass work in Box2D
As Bálint explained, mass in Box2D basically works according to Newton's laws of motion.
Sounds like what you're really after though is how mass works in Box2D in practical programmatic terms. As you'...
3
votes
Accepted
How detect collision between two bodies?
Answer
What you are looking for is called a Collision Callback. There is a great tutorial written by iforce2d on the topic, so I'll just give the key details here.
The strategy in Box2d is to ...
3
votes
Accepted
What's wrong with using physics engine in 2d platformer?
It's not necessarily a completely terrible idea but there are significant cons to weigh against the pros you mention. In particular, the physics in a platformer character usually isn't totally (or ...
3
votes
Having trouble implementing libGDX pause
This is actually, not LibGDX related at all. You just need to set a flag on your code boolean isPaused = false; or something alike, and change its value upon ...
3
votes
Accepted
Having trouble implementing libGDX pause
There's another more convenient way to pause your game: delta time manipulation. I prefer delta time manipulation because you do not have to individually place ...
3
votes
Accepted
Is there a "Least Terrible Method" for sharing Entities over Network?
Preface: I'm not familiar with Box2D, but these structures can be found in Boost Geometry (R-trees) if you are really interested, as well as other libraries:
Premature Optimization (Don't Do it)
...
3
votes
How to set a box2d body to follow a strict path
If you don't need the bat to be a Box2D Body then an easy way to achieve this is just to use a Spline, ...
3
votes
How can i collide two bodies without filtering(collision filtering)?
setfdef.isSensor = false;
and fixdef.isSensor = false;
A sensor shape collects contact information but never generates a ...
3
votes
Accepted
Character overlaps with static objects
The main problem is the drawn rotation in degrees does not match the simulated body's rotation in radians.
Your initial rotation of 45 is never applied to the body, so it is falling flat.
Box2D uses ...
2
votes
Ledge climb animation and movement (2d platformer)
i believe you need more design choices here before you can make a proper decission, specifically, what can happen to the character while he is hanging/climbing?
since you said the game is physics ...
2
votes
Accepted
Should I compute impact damage with energy or momentum?
If you want realism, you should consider that on impact kinetic energy can be transformed in a few different ways. It can cause movement, or be converted into other forms of energy, usually by ...
2
votes
Move body to mouse click and stop
Once you have the destination determined, it can be done in two popular ways:
Tweening. That is the most simple way of transforming an object to a
destination in exact N seconds with the ease ...
2
votes
Accepted
How to calculate move forward direction in Libgdx with Box2d body
Let's take your image as an example and make a triangle out of it (no hate on drawing skills haha).
By treating this problem like a triangle we can apply some trigonometry to this problem and ...
2
votes
Accepted
How to make the bullet stop accurately when destination is reached?
Quick & Dirty Way:
You can simply teleport the bullet to location you want after it stops.
Long & Better Way:
For the last moments of movement, you can disable the physics and control the ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
box2d × 817libgdx × 275
physics × 188
java × 126
c++ × 77
android × 61
collision-detection × 58
cocos2d-iphone × 51
andengine × 47
2d × 42
jbox2d × 30
javascript × 29
cocos2d × 28
platformer × 27
physics-engine × 24
sprites × 21
iphone × 20
farseer-physics-engine × 20
movement × 18
ios × 18
body × 17
unity × 15
sfml × 15
actionscript-3 × 14
mathematics × 13