Hot answers tagged physics
7
found a detailed breakdown of Mario Physics:
http://forums.mfgg.net/viewtopic.php?p=346301
http://i276.photobucket.com/albums/kk21/jdaster64/smb_playerphysics.png
5
If you look at the Farseer Physics Engine 3.3.1 Testbed XNA code, you'll find an example called OneSidedPlatformTest. Inside this test is the code required to create Fixtures that act in the manner you're requesting.
Essentially, you override the PreSolve function in the following way:
protected override void PreSolve(Contact contact, ref Manifold ...
4
I assume by "real" physics you really mean "realistic" physics. In almost every game that includes physics, unless it is a key feature of the game, the developers will take shortcuts to reduce processing time.
Quick answer: fake it with an animation.
Little longer answer: Reduce the number of pieces you process. You'd be surprised by how much time you save ...
4
In light of your question's context, http://nodewar.com/, there are a couple specific considerations for your solution:
You have a (low) maximum angular velocity, and enough maximum torque to reach it in very short time.
Your drone and target each have velocity and external acceleration unrelated to thrust (gravitation abounds).
Your desired target changes ...
3
Part of the problem is that your notion of 'velocity' isn't physical. Your updating of position is fine:
spriteYReal = spriteYReal + (spriteYVel * dt);
sprite.yScreen=(int) (spriteYReal*r.height);
This just says that the sprite's position is computed as Pnew = Pold+V*dt, which is fine - it means that V=dP/dt, which is correct. The problem is that the ...
3
Here are 3 standard (pre-calculus) kinematics formulae covering the case of constant acceleration, each with one of the unknowns (t, v, or _d) eliminated:
v^2 = u^2 + 2 a d
v = u + a t
d = u t + a (t^2) / 2
where:
u and v are the unitial and vinal (sic) velocities respectively;
t is the time;
d is the distance travelled in time t; and
a is the constant ...
3
A similar question, with some good answers, including the apparent name of this whole subject, "motion planning":
http://stackoverflow.com/questions/2560817/2d-trajectory-planning-of-a-spaceship-with-physics
As a programmer, I like the practicality of user470365's suggestion. However, I'll take a stab at a more rigorous approach. My suggestion here computes ...
3
It can be 1, it can be 3, it could even be more. This is a design decision that you need to make, based on a number of factors. Some of them are soft decisions based on your circumstances and preferences:
How much functionality (data and behaviour) is shared between the different types of bullets?
How large and complex is the project going to be in the ...
3
This is a really hard question to answer properly, because it really depends on the actual use case, your implementation, etc.
The more similar the behavior is, the more likely you could handle them all with one class, but due to this not necessarily being the case, other options might be more interesting.
E.g. if the only difference is their speed or ...
2
Demonstration:
Crude but functional collision detection and response
Video:
https://vimeo.com/64923588
The idea is that the player controlled sprite (actually a 32x32 pixels red box) can raise the speed of its next move, but it cannot go back to original speed except if it collide with something. Also if speed is enough the green wall can be "damaged" ...
2
Here's the correct code :
Vector2D weight(mass * gravity);
Vector2D buoyancy(immersedArea * fluidDensity * -gravity);
// assuming operator overloading of +
Vector2D totalForces(weight + buoyancy);
object->applyImpulse(totalForces);
In your code, you calculate mass * area_ratio * gravity but the weight does not depend on the immersed volume ...
1
In addition, the ball jumps weird when it touches two platforms at the
same time. Is there a possibility to avoid that weird jumping?
Nope your going to get that behavior with 2 platforms. You should combine them together into 1 shape. If the shape is more complex you can create a polygon that encompasses the entire area.
Anyways friction is going ...
1
Do you evade in the sense of "to flee" or "to (non-)cooperatively walk around each other"?
The answer to both questions is quite easy:
1) To let A flee away from B... let move A in the direct opposite direction of B relative to A. Which means: The direction vector should be Position(B) - Position(A). You'll then need to calculate the angle from this Vector ...
1
In X Men 2, Magneto shatters his glass prison with several marble sized metal balls, youtube.
In the DVD commentary the designers explian how they did the breaking effect. It was too computationally intensive to fully simulate it, instead they had an artist determine where the breaks would be (and where they'd look good). Then they scripted when the pieces ...
1
Drawing bounding boxes is a good solution, I have found. When I integrated BEPU into my engine I added code to do two things:
Draw the bounding box of the model in a certain color.
Draw the bounding box of the physics objects in another color.
This really helped me to find all the various issues between the two*, and makes the positions quite clear. ...
1
Here's a different algorithm; instead of stepping the player forward and moving him back if he's colliding, check where the next collision will occur:
Get the position of a corner of the object.
Shoot a line down (or up, or to the right/left, depending on your movement direction) from that position.
Figure out the first place that line intersects a ...
1
So, as per Mr. Geerkens suggestion, for the sake of completeness, here is the answer to the question.
A fantastic example of cloth simulation using a variety of integration methods can be found here. It has explicit and implicit methods, IMEX, FEM, runge-kutta and verlet. It comes with complete source code that is easy to understand and easy to compare to ...
1
Ok so I finally managed to work out what I was doing wrong.
The issue was how I was applying the rotation vector to the quaternion. Basically rather than use Quaternion.CreateFromAxisAngle() I now create a rotation change Quaternion using my angular velocity as the X,Y,Z components and 0 for the scalar. So just for clarity here is my new update code for ...
1
I tackled this problem recently using some of these answers as a starting point. The most helpful thing to keep in mind is that boids are a sort of simple n-body simulation: each boid is a particle that exerts a force on its neighbors.
I found the Linde paper difficult to read; I suggest instead looking at S.J. Plimpton's "Fast Parallel Algorithms for ...
Only top voted, non community-wiki answers of a minimum length are eligible

