OSC Receiver / Sender script for Unity

Drop this script into your Unity files and customize it to be able to control your Unity apps from other controllers / applications

OSC, Kinect, Unity, 3D

DOWNLOAD CODE

WATCH TUTORIAL VIDEO

OSC is a format for messaging among computers. I first heard about it when I met a performance artist who used it turn his iphone into a sound controller for Ableton Live, and shortly after when I watched a video from Kyle McDonald on how to use a beta software called Face Shift to do motion capture of a human face. The program allowed for streaming of motion data to other applications, and Kyle wrote a piece of software that converted that stream into OSC data - which can be accepted by a wide host of software programs. What I wanted to do is bring that OSC data into Unity, so that someone could use their face in order to look around in a first person shooter game.

Unity does not have any native method for controlling OSC data in the unpaid version (although there may be support in the commercial versions), but creative coder James George developed a project which utilizes OSC data to visualize the number of people in a 3D spaces. I simply paired his file down to a Unity project which captures and logs the messages and values transmitted via OSC - so you can use this file for whatever you want - music instruments, wii remote feedback, kinect feedback, etc.

Click here to download the project and open the OSCReceiver.Unity file in the "Assets" folder to get started. Attach the Unity OSCReceive script to a game object or the main camera, and you'll have a receiver set up. The receiver broadcasts the message to the OSCListener.cs script, where I have some commented out methods of how to read the data to the Debug Console. If you want to transmit OSC data, you'll need to attach the OSCSender script to the game object instead. The current code does not allow bidirectional communication.

Keep in mind you'll need to be transmitting OSC data before you run the Unity project (OSCulator is a good place to start if you've never experimented with that).