Mercuna now works with Unity!
Over the last month we have been hard at work integrating Mercuna with the Unity game engine. There is a long list of small features to be finished off, but the core of it is done and we have agents flying around Unity levels.
When we first started writing Mercuna, one of our design decisions was that we were going to initially focus on a single game engine in order to both simplify the architecture and to allow us to create a very tight integration with the chosen engine in order to ensure that Mercuna was as easy as possible to use. However, Mike and I come from a background of having worked on multi-engine middleware and found we couldn’t resist applying some of those ideas to Mercuna. For example, having our own types meant we could extend them as we wanted, and splitting Mercuna into several modules kept a nice clean separation of functionality.
Although we initially planned to target one engine, early on we decided that engine code in the core modules of Mercuna should be isolated to specific files, and generally be minimised. This decision really paid off, as now we have reached the point of extending Mercuna to integrate with other engines, it has made getting Mercuna working in a second engine fairly easy.
After our visit to GDC this year, one very clear piece of feedback we had received was that there was a lot of interest in using Mercuna by Unity developers, which therefore made Unity the obvious choice for our second engine integration.
The biggest challenge has been to interface with the C# Unity scripts, as Mercuna is written in C++. Thankfully it isn’t too difficult to call C++ libraries from C# but some care has been needed to ensure that types are converted back and forth correctly. The other big challenge was understanding Unity object lifetimes, particularly when executing in edit mode, and synchronizing the lifetimes across the C# to C++ interface. This took quite a while to fully understand and I plan to write a dedicated blog post on this in the near future.
With the main challenges now solved, we are able to build our navigation octree, search for paths, generate splines and steer agents along them. The remaining work items are now mainly fleshing out the configuration and debugging options within Unity, so it shouldn’t be too long until Mercuna with experimental Unity support, is ready to be released.
If you are interested in trying out Mercuna in Unity please get in touch, we would love to have some initial testers tell us what you think!
Now I wonder what engine we should do next…