Which physics engine is working with MonoGame?

Which physics engine do you use to develop Windows Phone games?
I tried Farseer Physics Engine but it’s not working with MonoGame and Windows Phone 8. Is there an alternative to Farseer that works with MonoGame and Windows Phone 8?

I just asked similar question. ( Physics anyone? )

Looks like Farseer is actually working. But i couldn’t manage to work with it either.

I tried to build Farseer from source code with no luck.

I wish someone will explain how to do that.

PS: I mean, i just downloaded source code, opened it with VS2013 and tried to build. But i gues we need to do someting more.


I had BEPU physics working with MonoGame a few weeks ago. I think I also had farseer working a long time ago, but I can’t remember if it was MonoGame or XNA.

With BEPU physics I had to create the project from scratch, probably you could do the same with Farseer (after all it’s probably just creating a folder and moving all the CS files, it will be surely faster than trying to figure why the project is not working)

I use Jitter physics, which is a pure C# physics engine. This means it should work on any platform:

I didn’t write it, but I did migrate the code to Git and Protobuild.

I recently recompiled Farseer to work with MonoGame.

It’s compiled has a portable class library, referencing the PCL fork of MonoGame so it probably won’t work out of the box but it should be significantly easier to get going.

At the very least I’ve stripped out everything you don’t need and fixed up some minor bits of code that didn’t work in a PCL.


I should probably get around to putting this stuff on github sometime. But until the official version of MonoGame has a core PCL library it’s not very easy to maintain.

I get this error message when I try to add a reference to the FarseerPhysics.Portable project:

Unable to add a reference to project ‘FarseerPhysics.Portable’. The current project’s target is not one of or compatible with the targets of Portable Library project ‘FarseerPhysics.Portable’.
A Portable Library project’s targets can be changed via the Library tab in the project’s properties.

I clicked on FarseerPhysics.Portable and the project’s targets are: .NET Framework 4, Silverlight 5
Should I change the targets? What should I change?

Sorry, maybe I didn’t make it clear before.

It will NOT work with the standard version of MonoGame.

This is what I use but it has been customised to my needs.

If you want to use it you’ll still need to create a new project that targets whatever platform you’re using (Windows Phone 8) and recompile the code. I provided the code in a zip file because I’ve already done some of the tricky changes.

I don’t have a Windows Phone, so I can’t really tell you exactly how to do it. Sorry about that.

Looks like none of them.

I was able to compile the source code of Farseer Physics Engine for use with MonoGame. I just needed to add the compiler directive XNA to my project. This is because the Farseer Code has some bits in that are not required by XNA or MonoGame and conflict with it.

I clicked on the FarseerPhysics.Portable project and changed the targets(properties–>Library–>Targets) from .NET Framework 4, Silverlight 5 to .NET Framework 4, Silverlight 5, Windows 8, Windows Phone Silverlight 8
After that, I could add a reference to the FarseerPhysics.Portable project. But it’s still not working. I always get many error messages that some assembly references are missing. I have only two assembly references in the FarseerPhysics.Portable project: .NET, MonoGame.Framework

Which assembly references should I add? For example, I get the following error message: The type or namespace name ‘Vector2’ could not be found (are you missing a using directive or an assembly reference?)
I want to use Farseer in a Windows Phone 8 MonoGame project.

I clicked on the FarseerPhysics.Portable project and changed the targets(properties–>Library–>Targets) from .NET Framework 4, Silverlight 5 to .NET Framework 4, Silverlight 5, Windows 8, Windows Phone Silverlight 8

The problem is that the standard version of MonoGame is NOT a portable class library. You can’t build FarseerPhysics.Portable without the PCL version of MonoGame found here:

I’m not sure if the PCL version of MonoGame currently supports Windows Phone 8. You could maybe ask @SimonDarksideJ about that.

I want to use Farseer in a Windows Phone 8 MonoGame project.

An alternative solution is to rebuild the project as a DLL that supports Windows Phone 8 rather than a PCL. I’m not sure how to do this because I’ve never done it before, but in theory you should just be able to create a new project and copy and paste all of the code into it.

The type or namespace name ‘Vector2’ could not be found (are you missing a using directive or an assembly reference?)

If you choose to rebuild the DLL to support WP8 you may actually run into the opposite problem. Some of the types (e.g. Vector2) will be defined twice. The correct way to solve it is to add a project level define e.g. XNA

Alternately, you could just not include those files into the project.

I know all this stuff is annoying. There have been some discussions about making it easier for MonoGame projects to support other libraries. For example, this one:

A Norwegian developer says he is going to make a presentation about Monogame + Farseer for Norwegian Developer Conferance at Oslo.

We still need to wait until 2-6 June to see the code he is built. I don’t know when the presantation video will be avaible.

PS : Maybe you can ask for early hint from him.

Here he is : Rune Grimstad

How can I add the project level XNA?

OK, time to break down some PCL myths :smiley:

MonoGame.Portable enables you to write effectively a “all platform” class library containing your game. The MonoGame.Portable library is just the stubs for MonoGame itself, there is no real code.
You would then have a real platform project using the real platform MonoGame and reference the Game Portable library (as you would any other class library) and you can run your game.

This is called the “bait and switch” method where it is only the version of MonoGame on the platform that actually runs, the PCL version is just an interface library in effect.

Right, on to Farseer.
As far as I can tell, farseer doesn’t have a Portable / PCL version, so I can only assume @craftworkgames has done a similar thing and created a stub project for the PCL library, which you could then use as a reference in your PCL class library game project (PCL’s can only reference other PCL’s)
To then use farseer in a project you would also need the actual platform implementation for farseer in your project the same as you do with Monogame.

Any supported platform can reference a PCL, not just other PCL libraries. So if there was a version of Farseer completely implemented in a PCL, you could just reference it from anywhere (so long as your platform matched the supported frameworks of the PCL)

Any clearer?

Hope this helps

Right, did a little investigation and there is a simple answer.

In the Farseer source there is a MonoGame version (fancy that), however it is a .NET 4 class library.

If you want to use this in a Windows Phone build you will need to create a Windows Phone (Silverlight V8.0) class library and copy the contents from the Farseer.MonoGame project to this new class library.
Then install the MonoGame.Binaries NuGet in to the class library and reference it from your Monogame.WindowsPhone project

Voilia you have farseer working with Windows Phone 8 and Monogame.

Creating a Bait and Switch PCL version of Farseer at the moment is no easy task and takes time.
However we are looking at tools to improve the pipeline for creating MonoGame.Portable and these are likely to be OS on the MG site, someone could then create a PCL version of Farseer using those tools if they wished :smiley:

@SimonDarksideJ tried that but didn’t work.

Going to try again now


I don’t know what i was doing wrong before but it is now working.

Going to continue writing a blog post about this.

Thank you @SimonDarksideJ

@SimonDarksideJ Actually, I managed to get the ENTIRE Farseer Physics library into a PCL. There’s no bait and switch going on here.

The only complicated bit is that Farseer needs some classes out of MonoGame to compile (e.g. Vector2, Vector3, Matrix). So in order to compile a PCL version of Farseer I needed to reference your PCL version of MonoGame. As you say, PCL’s can only reference other PCL’s.

This is also one of the reasons I’m in favor of splitting MonoGame up into different libraries. It’s a bit silly that to recompile Farseer we need to reference MonoGame in it’s entirety when it only uses a small handful of MonoGame’s classes.

BTW… Last night I started putting all this stuff on Github. It’s not quite ready to compile out of the box yet, but I’ll keep adding to it over the coming days.

Please post a link to it when you’re done. I’m interested to know everything about this stuff.

Be careful jumping to conclusions like that.

I know I just said this in the previous post, but let me just be clear. We don’t need a Bait and Switch PCL version of Farseer and creating a PCL version of Farseer was an easy task and that didn’t take much time. It’s already done and on github.

No problems, Keep calm and develop on (Gee’s I hate that meme)

1 Like