UniMove

Unity + C# + PlayStation Move controller == UniMove!

Introduction:

UniMove is an open-source Unity plugin and set of C# bindings that allows you to use PlayStation Move controllers with your Unity and/or C# application. Currently, the plugin only works on Mac OSX 10.5 and 10.6.

Update: We think the plugin works on 10.7, but we haven’t been able to fully test it yet.

UniMove was developed by Patrick Jarnfelt and Douglas Wilson of the Copenhagen Game Collective, and is based on top of Thomas Perl’s super-nifty C API. The plugin is licensed under the GNU Lesser General Public License (v2.1 or later), and is still under development.

The goal, as Thomas Perl put it, is:

… to implement a small and easy to use library to control the main functions of the controller (rumble and RGB LEDs) and to read the sensor values and button states from the controller. The broad availability of the controller, with its USB and Bluetooth connectivity, makes it an ideal candidate for building your own Ambient Orb-style ambient display.

Features include:

Download:

UniMove – version 0.1.0 (Beta) (14.6 MB) (July 20, 2011)

Includes:

Installation instructions:

  1. Start a new project, then go to:
    Assets –> Import Package –> Custom Package…
  2. Find and select UniMove.package
  3. In the “Importing package” window, press the “Import” button in the bottom right
  4. Viola! The assets (code, scene, plugin) should now be extracted and visible in your Project window. Double click the “Test Scene” scene to load it.  You should now be able to press the Play button to run the test program!

TODOs:

Shorter-term:

Longer-term:

Email us if you have any code to contribute, or if you want to get involved!

Frequently Asked Questions:

1. Is UniMove available for Windows?

It looks as though Thomas finally got the windows problems cracked. However the bluetooth setup on a windows machine is very dodgy and trial and error. But, the good news is that when the connection is established, the controller will connect and work impeccably.

We are working on integrating the windows dll, into our UniMove library. Stay tuned.

2. I can’t afford a Unity Pro license! Can I still use UniMove ?

Unfortunately, you do need a Unity Pro license in order to use plugins (i.e. external .dll and .bundle files).

However, you could use our C# bindings and make your own project using the MonoDevelop IDE. It’s a little tricky, but definitely possible – we’ve actually done it ourselves. In the near future, we hope to release a .sln (starter project) and short tutorial. Meanwhile, in our download we’ve included the .dylib file (the OSX equivalent of a .dll) that you’ll need to get started. See our .cs files for an example of how to reference code from a .dylib/.dll in a C#.

Careful, it get be frustrating to get MonoDevelop to “see” external .dylib files. You may need to use a special .config file. For more info, read this very useful and extensive page about Mono and interop with native libraties. Also, OSX seems to be picky about how your reference the .dylib prefix and suffix in your C# code. Again, do read that reference page if you’re going to try to use the C# bindings outside of Unity.

Finally, if all else fails, you could always just use Thomas Perl’s lower-level API – available in C, Qt/C++, and Python.

3. Does UniMove work on OSX 10.4 or earlier?
Actually we don’t really know. Update: Thanks to our friend Richard, we’ve now tested it on 10.4. It doesn’t seem to work.

We suspect we could possibly get it to work if we recompiled the .bundle on 10.4. But right now it isn’t one of our immediate priorities.

4. What is a .bundle file?
You’ll notice that the plugin comes with a .bundle file. That’s basically an OSX version of a .dll. Usually, on OSX you’d use a .dylib, but Unity only takes .bundle or .dll files.

If you’re going to try to use our bindings outside of Unity, you’ll want to use the .dylib that we also included (see above, Question #2).

5. How do I connect the controllers via Bluetooth? And what is “pairing”?

This gets a tiny bit complicated. You’ll need to both “pair” and “connect” the Move controllers. Each Move controller stores the hardware address of one target device (i.e. a computer or PS3). Setting that address – that is, tethering the controller to a specific computer – is called “pairing”. To do this, you’ll need to physically connect the controller by mini-USB cable. Once you pair a controller, you won’t ever have to pair it again – or at least until you overwrite that address by pairing the controller to some other device.

We’ve included our own Pairing Utility (along with the source code). Feel free to package it together with your own application. You could also write your own pairing code/utility, of course. See the Pairing Utility code to see how that’s done. Thomas Perl’s original C API actually provides functions for manually setting/getting the Bluetooth address, but we were just able to use his auto-magic psmove_pair() function.

Once a controller is paired, you still need to press the small circular “PS” button to finally “connect” it to OSX (you don’t need the mini-USB cable for this step). If successful, you should see the controller show up in the OSX Bluetooth Preferences panel. Unlike the pairing process, you’ll need to connect the controllers again every time you restart your computer.

Note: if a controller gets unexpectedly disconnected (i.e. it goes out of range), you’ll sometimes need to manually remove it from the OSX Bluetooth Preferences panel before you can re-connect it.

6. How many controllers does UniMove support?

6-7 controllers – apparently there’s actually a hardware limit (7?) on the number of Bluetooth devices that can be connected at any one time.

However, we should note that we’ve found that older/slower computer can have trouble keeping up. This sluggishness seems to increase proportionally to the number of controllers that are connected. We’re still not entirely sure why, and we’d be curious to hear if anyone has a smart workaround. Our own somewhat kludge-y workaround has been to increase, when needed, the frequency of the controllers’ update loop. Our API offers a simple property where you can adjust this frequency. This is why our API doesn’t use Unity’s FixedUpdate() function – we figured that people might want to adjust the frequency of their controllers’ update loop independently of the rest of their application.

Credits:

UniMove was developed by Douglas Wilson and Patrick Jarnfelt

The music used in the Pairing Utility is by Nicklas “Nifflas” Nygren, and comes from the B.U.T.T.O.N. soundtrack.

A very special thanks to Thomas Perl, who authored the C code on top of which this project is based (and who gave us excellent and patient tech support!). Thomas’ code, in turn, uses Alan Ott’s multi-platform hidapi.

And thanks to the rest of the collective, as well as Brandon, Greg, Tiff, Adam, Marek, Nick, Derek, and Rune, for testing and feedback!

For questions and comments, send us an email.

Version History and Updates:

2011-07-20: Version 0.1.0 (Beta)
First public release! Give it a whirl and tell us what you think!