28

I would recommend checking out the explosion iforce2d page. It does a great job going over the various ways of handling explosions with the performance vs. accuracy tradeoffs. It goes over 3 methods which I will summarize here. So this is simply me summarizing information I found while researching and none of it is my own work. Also you want to apply ...


7

Steering behaviors work very well in combination with a physics-engine, as they are usually implemented in a way that they return a "steering force" which can then be applied to your physics-body. To make a unit follow a path, you could use Seek to go from path-node to path-node (make sure to avoid overshoot) and then use Arrival at the last node in your ...


7

The answer is simple: a physics engine is not a platformer engine. While you can get kind-of platformer-like behaviour out of a physics engine, you simply do not have enough control to get that really "fluid" gameplay feel of a proper platformer. For example: The classic Mario-style jump requires changing the gravity for the player at different stages of ...


7

atan2 is a mathematical function; it is stateless. There is nothing in it to “know” that you want an angle which is close to the angle from the previous frame, as opposed to an angle which is simply sufficient to identify the direction. You must write your own logic to handle this case. There are several possible behaviors you could implement; here's the ...


7

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 ...


6

Ok, after about two hours of tinkering I managed to do this but it requires adding some extra bodies. You'll probably want to extract this stuff into a method/class but the basic idea is this: Create what I call "holder" bodies for your objects. These bodies share the size and position of your "objects" but don't participate in collisions. Essentially, they ...


5

Do what your game does to start up. The simple, dumb way would be to re-initialize all your objects and variables as they do in the initialization of your game. You could be clever here, and only reload those elements that are modified during game-play (your models, maps, and textures likely don't change, for instance). If your character / gameworld has ...


4

I guess the revoulte joint is what you want. You can use it to pin the circle at a given position and the circle will rotate around that position.


4

Please take my answer as "the right way to do this", not necessarily the "good for a student project" way. Rigid body physics are entirely inappropriate for modeling "walking" behaviour. Rigid body physics are good for handling things like bouncing and friction. Which are things you want to avoid in a typical platformer. There is no "right shape" that will ...


4

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 add friction or clamp Body.AngularVelocity or both. Adding friction/damping will reduce acceleration gradually. Clamping velocity will put a hard limit on the ...


3

What I do is add a Texture2D directly to my game objects. I have another class called an AnimationController which manages my source rectangle/frames/timing for drawing animations from the texture. I suppose this would be similar to what your Sprite class does. If my game object will have a physics body (i.e. players, enemies, etc.), I add a Body property ...


3

Finally works! I had the vertices of the contour as a sequence, so the solution was use the LoopShape to create the fixture of the body. I did not even know that Class =P LoopShape loopShape = new LoopShape(farseerVertices); //Delete the previous fixture farseerBody.DestroyFixture(previousFixture); //Create new fixture with the new contour farseerBody....


3

Send logical data, not presentation. Most games will never send graphics or textures to other systems during gameplay. Each system should already have all the resources it needs to render the events; you just send information about which events have taken place.


3

Farseer does ship a physics view, and thankfully it requires very little brain power to implement and use. If you downloaded the "Farseer Physics Engine 3.3.1 Samples XNA" recommended package on their download page, you'd see a lot of examples included. Navigate to (or click these convenient links to the codeplex page :P) SamplesXNA/SamplesXNA/ScreenSystem/...


3

float angle = MathHelper.ToRadians(45); float power = 20; // <- tunable value Vector2 direction = new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle)); fixture.Body.ApplyLinearImpulse(power * direction); The above applies an instantaneous force to the object. You could also set Body.LinearVelocity directly. To check for the space key being ...


2

Does the erroneous line in your World.step() method have square brackets in it anywhere? Or a get() method of some sort with an index in it. This error suggests that you're asking for an object in an array or list by providing an index outside of the array bounds. Array bounds start at 0, and end at array.Length - 1. So a lot of the time this error is ...


2

It is actually really easy for (int i = 0; i < origin.body.FixtureList.Count; i++) { origin.body.DestroyFixture(origin.body.FixtureList[i]); } FixtureFactory.AttachCompoundPolygon(verticeslist, 1f, origin.body, null); return origin.body;


2

The solution was finally found in the Box2D forum. The negine has a velocity threshold. If velocity drops below that it is set to 0. The default value is 1.0. I changed it to 0.1 and voilà it behaves correct, even when using linear damping. The constant is defined in FarseerPhysics.Settings.VelocityThreshold


2

Here is my code for drawing Farseer debug objects. They line up perfectly with my real world objects. I had to play around with it for a long time before I got it to draw just right. This may be of use to you. Matrix proj = Matrix.CreateOrthographicOffCenter(0f, Viewport.Width, Viewport.Height, 0f, 0f, 1f); Matrix view2 = Matrix.CreateScale(32); view2 *= ...


2

I know this question was already answered but I needed this in one of my games as well and I found the answer in the Farseer forums and modified it for my engine. You will find the original link in the comments (Shameless link to engine http://code.google.com/p/axiosengine/ - perhaps you will find more interesting things there) : namespace Axios.Engine....


2

I think when you create a physics body, the body's position is considered to be at its center of mass - which in this case since it's a rectangle, the center of mass is exactly in the middle of the rectangle. But you're drawing the sprite using the physics body position as if it were the top left corner of the sprite, instead of its center. For starters ...


2

Farseer Bodies have a method like so: body1.IgnoreCollisionWith(body2); What you are asking for is so that a body will only collide with another body once, so once those two bodies are separated from each other, they will no longer collide. Luckily, Farseer bodies come with an OnSeparation event. body.OnSeparation += OnSeparation; private void ...


2

Physics engines and tile based platformers are not mutually exclusive. For example you can combine the Farseer Physics engine and the XNA Platformer Starter Kit (This will also explain a pure tile based approach to you). Simply remove all exisiting collision detection code (from the Player class) and give the Tiles and Player class Bodies and associated ...


2

I think the easiest way would be to just create some geometry you can actually texture. Just create a quad (2 triangles) for every segment of your world. This should be straight-forward to texture. To optimize this, you can remove quads that leave the screen during gameplay. For an idea how you could apply your texture using UV coordinates, see this answer.


2

I noticed this question has been around for a while unanswered so I thought I'd put some information here for future reference. It's not a complete answer, but it might help the next person. Is seems there are a number of open issues with lots of discussion around this issue and why it's difficult to implement. https://github.com/mono/MonoGame/issues/1405 ...


2

Are you just adding force to the ball? If you need elastic collisions don't do this. Farseer body has property called restitution, it controls ratio of the speed before and after collision.


2

Problem solved with: world.ContactManager.PreSolve += new PreSolveDelegate(PreSolve);


2

If your project is 7.1 and Farseer is 7.0 Right click the Farseer project and click Upgrade to Windows Phone 7.0. If your project is 8.0 and Farseer is 7.1 or below To upgrade to WP8.0 is more of a pita though not too bad. You will need to edit the csproj file for both projects. So for both of them. Right click the project in the solution explorer and ...


2

Ok, so obviously Position is simply the position of the Body in the world. In order to fully explain GetLocalVector and GetWorldVector, I will also explain the GetLocalPoint and GetWorldPoint methods. As you say, Farseer's documentation is not great. My advice is to build it from source within your own Solution, so you can easily investigate what's going ...


2

The speed of a body should be available via the LinearVelocity property. A simple version of the answer is this: var km = 1000f; var hour = 3600f; if(myBody.LinearVelocity.Length() > (50*km/hour)) { var direction = Vector2.Normalize(myBody.LinearVelocity); myBody.LinearVelocity = direction*(50*km/hour); } A more advanced but efficient way of ...


Only top voted, non community-wiki answers of a minimum length are eligible