In this tutorial, you will get the basic ideas of interactive connection between Unity and Max/Msp, using open sound control (OSC[[OSC|Open Sound Control]]).
You will try to control noise deformation intensity of a mesh object as an example.
There are some materials you need to test this tutorial.
Please download and install following plugins before you start;
-OSC[[OSC|Open Sound Control]] plugins for Unity
-OSC[[OSC|Open Sound Control]] plugins for Max/Msp
-Perlin noise plugin for Unity
-Scripts for Unity
In this section, you will make a OSC[[OSC|Open Sound Control]] sender part on Max/Msp.
1.Open a new patcher from top menu bar. You can also make a new patcher with shortcuts "command" + "K".
2.Press "F" key to make a number box for float. This will be the input of the noise contoroller.
3.Press "M" key to make a message node and type "/test $1" and connect with the number box.
"/test" is an identifier of the osc message. You can rename whatever you want, but you should pay attention not to forget "/" before the name of identifier.
Also, "$1" is required to import external value.
4.Press "B" to make a bang node and press "N" and type "OpenSoundControl".
5.Press "N" and type "udpsend 127.0.0.1 2222".
"127.0.0.1" is a IP1. Internet Protocol 2. Intellectual property address, which is used to test this setup internally.
If you try this tutorial with multiple computers, check the IP1. Internet Protocol 2. Intellectual property address of a computer for Unity project.
"2222" is a name of port. You can define any integer, but make sure that you are using the same port number for Max patch and Unity.
7. Then, lock the patcher with "command"+ "E". Now you are ready to run the "sender" part.
In this section, you will make OSC[[OSC|Open Sound Control]] receiver part on Unity.
1.Open Unity and make a new project folder.
Click the "NEW" icon on the top right of the window to make a new project folder.
Make sure that you are selecting "3D" mode. If you are selecting, its color is red.
Create 2 folders and name them "Scripts" and "Plugins".
Then, right click created game object and rename it "OSC[[OSC|Open Sound Control]] Receiver".
In this tutorial, all scripts related to OSC[[OSC|Open Sound Control]] will be attached on this game object.
3.Right click on the "Project" tab on the bottom left of the window.
4. Click "OSC[[OSC|Open Sound Control]] Receiver" game object. The detailed information about this game object appears on the "Inspector" tab on the right side of the window. Drag and drop"Osc.cs", "Udp.cs" and "OSCReceiver.js" on it.
Then, drag and drop downloaded Unity plugins named "Osc.cs", "Udp.cs", "Perlin.cs" to "Plugins" folder.
Also, you drag and drop Unity scripts called "OSCReceiver.js" to "Scripts" folder.
In Unity, there are some special folder name for specific types of objects.
You can find detailed information on References part.
If you try it with multiple computers, modify parameters of "OSC[[OSC|Open Sound Control]] Receiver" script on the Inspector tab.
5. If you try this tutorial on your computer internally, make sure that "OSC[[OSC|Open Sound Control]] Receiver" script uses the same IP1. Internet Protocol 2. Intellectual property address and port name on "Listener Port".
At last, you will make animated object.
1.Drag and drop "NoiseDeform.js" script, which is included in the UnityNoise_Scripts.zip, on the "Scripts" folder on the "Project" tab.
Also, drag and drop the perlin noise plugin "Perlin.cs" on the "Plugins" folder.
2.Create a sphere. Normally the default size of the sphere is too small when it's seen from the default camera position,
so you can make it bigger by pressing "R" key and drag the center cube of the gizmo.
You can check the size of sphere from the camera position when you click your camera object on the "Hierarchy" tab.
4.click the sphere and drag and drop "Noisedeform.js" on the "Inspector" tab.
Then, lock your max patch with "command" + "E" and drag on the number box.
5. Now it's ready to test. Press "command" + "P" key to run the project.
If your unity project shows deformed sphere, it's working.
You can adjust the amplitude of the noise by dragging on the number box of your max patch.
You can downloaded finished sample project files from this link;
There is detailed description about special folder name on Unity project.