how to get Mercury Particle Engine working in XNA 4.0

I've been messing around recently with a really cool particle engine for XNA called Mercury Particle Engine. This engine looks to have some great features and an active development cycle but the documentation can be very lacking.

One query that I keep seeing on their forums is how to actually go about and include it in a simple XNA 4.0 project.

I have attached a simple working project below but if you want to manually setup the particle engine in your existing project here are the steps you'll need to do:

  1. Downloaded Mercury Particle Engine 3.1 for XNA 4.0 (Binaries)
  2. Unblocked the zip file (right click the file and click on Unblock).
  3. Open Visual Studio 2010 and create a new Windows XNA 4 project.
  4. Copy the ProjectMercury.dll and ProjectMercury.ContentPipeline.dll files and place these into your game project in the root level or in a folder called ParticleEngine, whichever you choose.
  5. Check the properties of both files and set the Build Action to 'Content' in Visual Studio.
  6. Add a reference to the file ProjectMercury.dll in your game project.
  7. Add a reference to the files ProjectMercury.dll and ProjectMercury.ContentPipeline.dll in your content project.
  8. Copy the EffectLibrary and Textures from the editor example into your content project (so you now have all the textures and xml files at your disposal).
  9. Do a build and more than likely you will get some errors about some of the Effect XML files. This appeared to be down to 3 of them using the word 'True' instead of 'true' (all lowercase) on certain sections so replaced them and everything should build for you.
  10. Run through the steps from this blog article: http://xnacoding.blogspot.com/2010/07/how-to-mercury-particle-engine.html
  11. You need to make one change to the code from link above. This is where I stumbled initially. The LoadContent method should contain the following code rather than the code from that example:>
// load particle effects
myEffect = Content.Load(@"EffectLibrary\BasicExplosion");
myEffect.LoadContent(this.Content);
myEffect.Initialise();
myRenderer.LoadContent(Content);

When you build and run your project you should now be able to left mouse click and see an explosion particle effect on screen. Pretty cool! If you want to run a different effect simple rename BasicExplosion in the code above to whatever filename is on the XML file in the Effect folder you imported. Just be sure not to include the '.xml' extension.

Click here to download a sample XNA 4 project with Mercury Particle Engine.

blog comments powered by Disqus

Get In Touch

Follow me online at TwitterFacebook or Flickr.

Latest Tweets